Skip to content

Commit

Permalink
Download mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vslinko committed Nov 28, 2012
1 parent 662fa1a commit be66023
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -24,3 +24,11 @@ tio
```
tio -v
```

---

Download tracks without playing

```
tio -d
```
2 changes: 1 addition & 1 deletion package.json
@@ -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",
Expand Down
31 changes: 21 additions & 10 deletions tio.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit be66023

Please sign in to comment.