Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweet that clip #88

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
os: osx
# https://docs.travis-ci.com/user/reference/osx/#macos-version
osx_image: xcode9.4
language: node_js
node_js: "8"
node_js: "8" # one of node js travis pre installed versions
sudo: required

env:
Expand Down
59 changes: 58 additions & 1 deletion electron/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
window.BBCKeys = require('./bbc_keys.js').getBBCAPIkeys;
window.setBBCAPIkeys = require('./bbc_keys.js').setBBCAPIkeys;
window.areBBCAPIkeysSet = require('./bbc_keys.js').areBBCAPIkeysSet;

window.TwitterAPIkeys = require('./twitter_keys.js').getTwitterAPIkeys;
window.setTwitterAPIkeys = require('./twitter_keys.js').setTwitterAPIkeys;
window.areTwitterAPIkeysSet = require('./twitter_keys.js').areTwitterAPIkeysSet;
}

if(window.ENV_CEP){
Expand Down Expand Up @@ -132,6 +136,9 @@
window.setBBCAPIkeys = require(`${envPath}/bbc_keys.js`).setBBCAPIkeys;
window.areBBCAPIkeysSet = require(`${envPath}/bbc_keys.js`).areBBCAPIkeysSet;

window.TwitterAPIkeys = require(`${envPath}/twitter_keys.js`).getTwitterAPIkeys;
window.setTwitterAPIkeys = require(`${envPath}/twitter_keys.js`).setTwitterAPIkeys;
window.areTwitterAPIkeysSet = require(`${envPath}/twitter_keys.js`).areTwitterAPIkeysSet;
}

if(window.ENV_BROSWER){
Expand Down Expand Up @@ -178,9 +185,20 @@
console.info("placeholder funciton", keys);
}

window.setBBCAPIkeys= function(keys){
window.setBBCAPIkeys = function(keys){
console.info("placeholder funciton", keys);
}

window.TwitterAPIkeys = function(keys){
console.info("placeholder funciton", keys);
}
window.setTwitterAPIkeys = function(keys){
console.info("placeholder funciton", keys);
}
window.areTwitterAPIkeysSet = function(keys){
console.info("placeholder funciton", keys);
}

}

</script>
Expand Down Expand Up @@ -348,6 +366,7 @@
}
///////////////////////
if(window.ENV_ELECTRON){
const fs = require('fs');
ffmpegExentions = require("./ffmpeg_extentions.js");
// TODO: move code below so that it can work in chromium as well
// file dialogue opener
Expand Down Expand Up @@ -400,6 +419,44 @@
})
}

const electron = require('electron');
const currentWindow = electron.remote.getCurrentWindow();
const dataPath = currentWindow.dataPath;
window.dataPath = dataPath;
const tweetThatClip = require('tweet-that-clip');

window.tweetThatClip = function(infoToTweet){
if(infoToTweet.captionsBool){
fs.writeFileSync(infoToTweet.srtFilePath, infoToTweet.srtFileContent)
}

return new Promise((resolve, reject)=>{
// set credentials in process.env.
console.log('tweetThatClip - started in index.html');
// adding path to electron
infoToTweet.ffmpegBin = require("ffmpeg-static-electron").path;
infoToTweet.credentials = window.TwitterAPIkeys();
// TODO: tmpDir
infoToTweet.tmpDir = path.join(dataPath, 'tmp_media');
// TODO: could add burn in captions, either before, or as option inside the twitter module,
// as optional submodule
// https://github.com/pietrop/captions_burner/blob/master/lib/burn_srt_on_video.js
// console.log('tweetThatClip',process.env.TWITTER_CONSUMER_KEY);
tweetThatClip(infoToTweet)
.then((res) => {
// TODO: add some kind of tweted message
console.log('tweeted - index.html');
console.log(res);
// cb(null,res);
resolve(res);
})
.catch((err)=>{
// cb(err,null);
reject(err);
});
})
}


}

Expand Down
9 changes: 8 additions & 1 deletion lib/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ module.exports = Backbone.Router.extend({

settingsPanel: function() {
console.debug('Router: settings panel: ');
var tmpSettings = {credentials: {ibm: window.IBMWatsonKeys(), speechmatics: window.SpeechmaticsKeys(),rev: window.revKeys(), bbc: window.BBCKeys(), assemblyai: window.AssemblyaiAPIkeys() }} ;
var tmpSettings = {credentials: {ibm: window.IBMWatsonKeys(),
speechmatics: window.SpeechmaticsKeys(),
rev: window.revKeys(),
bbc: window.BBCKeys(),
assemblyai: window.AssemblyaiAPIkeys(),
twitter: window.TwitterAPIkeys()
}
} ;
var settingsView = new SettingsView({settings: tmpSettings});
displayMain(settingsView);
},
Expand Down
41 changes: 41 additions & 0 deletions lib/app/templates/settings_template.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<li role="presentation"><a href="#assemblyai" aria-controls="assemblyai" role="tab" data-toggle="tab">AssemblyAI</a></li>
<li role="presentation"><a href="#rev" aria-controls="rev" role="tab" data-toggle="tab">Rev</a></li>
<li role="presentation"><a href="#bbc" aria-controls="bbc" role="tab" data-toggle="tab">BBC</a></li>
<li role="presentation"><a href="#twitter" aria-controls="twitter" role="tab" data-toggle="tab">Twitter</a></li>
<!-- <li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li> -->
</ul>
<!-- Tab panes -->
Expand Down Expand Up @@ -199,6 +200,46 @@
</div>
<!-- BBC tab end -->


<!-- Twitter tab -->
<div role="tabpanel" class="tab-pane" id="twitter">
<br>
<div class="alert alert-info alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Twitter Credentials</strong>
<p>This service is for being able to tweet clips to your twitter account.</p>
<p>In order to use this service you need to get developer credentials, see user manual for more informations.</p>
</div>

<!-- rev credentials form -->
<form id="form">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<h3>Twitter credentials</h3>
<div class="form-group">
<label for="username">Twitter Consumer Key</label>
<input type="text" name="tiwtter-consumer-key" value="<%= credentials.twitter.consumerKey %>" class="form-control" id="tiwtterConsumerKey" placeholder="e.g. HhGDjGYnLHhGDjGYnL">
</div>
<div class="form-group">
<label for="username">Twitter Consumer Secret</label>
<input type="text" name="tiwtter-consumer-secret" value="<%= credentials.twitter.consumerSecret %>" class="form-control" id="tiwtterConsumerSecret" placeholder="e.g. HhGDjGYnLHhGDjGYnL">
</div>
<hr>
<div class="form-group">
<label for="username">Twitter Access Token</label>
<input type="text" name="tiwtter-access-token" value="<%= credentials.twitter.accessToken %>" class="form-control" id="tiwtterAccessToken" placeholder="e.g. HhGDjGYnLHhGDjGYnL">
</div>
<div class="form-group">
<label for="username">Twitter Access Token Secret</label>
<input type="text" name="tiwtter-access-token-secret" value="<%= credentials.twitter.accessTokenSecret %>" class="form-control" id="tiwtterAccessTokenSecret" placeholder="e.g. HhGDjGYnLHhGDjGYnL">
</div>
<a id="submitBtnTwitterCredentials" class="btn btn-primary">Save Twitter Credentials</a>
</div><!-- ./col -->
</div><!-- ./row -->
</form>
</div>
<!-- Twitter tab end -->

<!-- <div role="tabpanel" class="tab-pane" id="settings">...</div> -->
</div>

Expand Down
Loading