Skip to content

Commit

Permalink
option to skip file cache
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Sep 27, 2015
1 parent fa6d336 commit 64e9b61
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions bin/ytdl.js
Expand Up @@ -81,6 +81,11 @@ var opts = require('nomnom')
flag: true,
help: 'Print direct download URL'
})
.option('noCache', {
full: 'no-cache',
flat: true,
help: 'Skip file cache for html5player'
})
.option('debug', {
flag: true,
help: 'Print debug information'
Expand All @@ -91,17 +96,19 @@ var opts = require('nomnom')
;


// Keep cache in file.
var cachefile = path.resolve(os.homedir(), '.ytdl-cache.json');
fs.readFile(cachefile, function(err, contents) {
if (err) return;
ytdl.cache.store = JSON.parse(contents);
});
if (opts.cache !== false) {
// Keep cache in file.
var cachefile = path.resolve(os.homedir(), '.ytdl-cache.json');
fs.readFile(cachefile, function(err, contents) {
if (err) return;
ytdl.cache.store = JSON.parse(contents);
});

ytdl.cache.set = function(key, value) {
ytdl.cache.store[key] = value;
fs.writeFile(cachefile, JSON.stringify(ytdl.cache.store, null, 2));
};
ytdl.cache.set = function(key, value) {
ytdl.cache.store[key] = value;
fs.writeFile(cachefile, JSON.stringify(ytdl.cache.store, null, 2));
};
}


/**
Expand Down

0 comments on commit 64e9b61

Please sign in to comment.