Permalink
Browse files

Download mode

  • Loading branch information...
vslinko committed Nov 28, 2012
1 parent 662fa1a commit be6602372db2e1ff193bd126ba3990a2095558a4
Showing with 30 additions and 11 deletions.
  1. +8 −0 README.md
  2. +1 −1 package.json
  3. +21 −10 tio.js
View
@@ -24,3 +24,11 @@ tio
```
tio -v
```
+
+---
+
+Download tracks without playing
+
+```
+tio -d
+```
View
@@ -1,6 +1,6 @@
{
"name": "tio",
- "version": "0.0.6",
+ "version": "0.1.0",
"description": "tines.io console player",
"keywords": ["tunes.io", "audio", "music", "player"],
"homepage": "https://github.com/rithis/tio",
View
31 tio.js
@@ -20,33 +20,30 @@ var optimist = require('optimist')
.alias('h', 'help')
.alias('l', 'library')
.alias('i', 'inline')
+ .alias('d', 'download')
.default('t', 3)
.default('l', util.format('%s/%s', process.env['HOME'], '.tio-library'))
.string('l')
.describe('v', 'Print more information about process')
.describe('t', 'Threads for downloading')
.describe('l', 'Path to your library')
.describe('V', 'Print version information and exit')
- .describe('i', 'Use UI based on stdout, not ncurses'),
+ .describe('i', 'Use UI based on stdout, not ncurses')
+ .describe('d', 'Download tracks without playing'),
argv = optimist.argv;
if (argv.help) {
optimist.showHelp();
process.exit();
} else if (argv.version) {
- console.log('0.0.6');
+ console.log('0.1.0');
process.exit();
}
// preparing
-var win = ui.factory(argv.inline, argv.verbose);
-var player = spawn('play', [
- '--no-show-progress',
- '--volume', '.5',
- '--type', 'mp3',
- '-'
-]);
+var win = ui.factory(argv.download || argv.inline, argv.download || argv.verbose);
+var player = null;
var library = [];
var libraryPath = argv.library;
var currentTrack = null;
@@ -87,6 +84,15 @@ var stop = function () {
};
var playNext = function () {
+ if (!player || !player.readable) {
+ player = spawn('play', [
+ '--no-show-progress',
+ '--volume', '.5',
+ '--type', 'mp3',
+ '-'
+ ])
+ }
+
var track = library.shift();
library.push(track);
@@ -242,7 +248,12 @@ if (!fs.existsSync(libraryPath)) {
fs.mkdirSync(libraryPath);
}
-syncLibrary();
+if (argv.download) {
+ playNext = new Function();
+} else {
+ syncLibrary();
+}
+
fetchPlaylist();
for (var i = 0; i < argv.t; i++) {
downloadTrack();

0 comments on commit be66023

Please sign in to comment.