Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

used `path.join` to make it more cross-platform

  • Loading branch information...
commit 05c2ba34512ccd9a96e6856828fd0c65e9a80701 1 parent b5fb4bf
Roly Fentanes authored March 04, 2012
4  example/download.js
... ...
@@ -1,7 +1,7 @@
1  
-youtubedl = require('..');
  1
+var ytdl = require('..');
2 2
 
3 3
 
4  
-dl = youtubedl.download('http://www.youtube.com/watch?v=90AiXO1pAiA',
  4
+dl = ytdl.download('http://www.youtube.com/watch?v=90AiXO1pAiA',
5 5
   __dirname,
6 6
   // optional arguments passed to youtube-dl
7 7
   ['--max-quality=18']);
4  example/info.js
... ...
@@ -1,6 +1,6 @@
1  
-youtube = require('..');
  1
+var ytdl = require('..');
2 2
 
3  
-youtube.info('http://www.youtube.com/watch?v=WKsjaOqDXgg',
  3
+ytdl.info('http://www.youtube.com/watch?v=WKsjaOqDXgg',
4 4
   
5 5
   // called when video page is downloaded and info extracted
6 6
   function(err, info) {
6  lib/youtube-dl.js
@@ -32,7 +32,7 @@ var parseOpts = function(args) {
32 32
 };
33 33
 
34 34
 // check that youtube-dl file exists
35  
-var file = path.normalize(__dirname + '/../bin/youtube-dl');
  35
+var file = path.join(__dirname, '..', 'bin', 'youtube-dl');
36 36
 path.exists(file, function(exists) {
37 37
   if (exists) return;
38 38
 
@@ -117,9 +117,7 @@ var regex = /(\d+\.\d)% of (\d+\.\d+\w) at\s+([^\s]+) ETA ((\d|-)+:(\d|-)+)/;
117 117
 // main download function
118 118
 exports.download = function(url, dest, args) {
119 119
   // setup settings
120  
-  if (dest == null) {
121  
-    dest = './';
122  
-  }
  120
+  dest = dest || process.cwd();
123 121
   if (args == null) {
124 122
     args = [];
125 123
   } else {
2  scripts/download.js
@@ -4,7 +4,7 @@ var fs    = require('fs')
4 4
   , exec  = require('child_process').exec
5 5
 
6 6
 
7  
-var folder = path.normalize(__dirname + '/../bin')
  7
+var folder = path.join(__dirname, '..', 'bin')
8 8
   , filename = '/youtube-dl'
9 9
   , filepath = folder + filename
10 10
 
14  test/download.js
... ...
@@ -1,9 +1,9 @@
1  
-var vows = require('vows')
2  
-  ytdl   = require('..'),
3  
-  fs     = require('fs'),
4  
-  path   = require('path'),
5  
-  assert = require('assert'),
6  
-  video  = 'http://www.youtube.com/watch?v=90AiXO1pAiA';
  1
+var vows   = require('vows')
  2
+  , ytdl   = require('..')
  3
+  , fs     = require('fs')
  4
+  , path   = require('path')
  5
+  , assert = require('assert')
  6
+  , video  = 'http://www.youtube.com/watch?v=90AiXO1pAiA'
7 7
 
8 8
 
9 9
 vows.describe('download').addBatch({
@@ -35,7 +35,7 @@ vows.describe('download').addBatch({
35 35
 
36 36
     'file was downloaded': function(err, data) {
37 37
       // check existance
38  
-      var filepath = __dirname + '/' + data.filename;
  38
+      var filepath = path.join(__dirname, data.filename);
39 39
       assert.isTrue(path.existsSync(filepath));
40 40
 
41 41
       // delete file after each test
8  test/info.js
... ...
@@ -1,7 +1,7 @@
1  
-var vows = require('vows')
2  
-  ytdl   = require('./../lib/youtube-dl'),
3  
-  assert = require('assert'),
4  
-  video  = 'http://www.youtube.com/watch?v=90AiXO1pAiA';
  1
+var vows   = require('vows')
  2
+  , ytdl   = require('..')
  3
+  , assert = require('assert')
  4
+  , video  = 'http://www.youtube.com/watch?v=90AiXO1pAiA'
5 5
 
6 6
 
7 7
 vows.describe('info').addBatch({

0 notes on commit 05c2ba3

Please sign in to comment.
Something went wrong with that request. Please try again.