6 Commits
1.1.1 ... 1.1.2

Author SHA1 Message Date
Roel van Uden
887b3ed094 Bump the version 2015-03-06 22:22:53 +01:00
Roel van Uden
49e3290f28 Fixing the README while I'm at it 2015-03-06 22:17:45 +01:00
Roel van Uden
5d32d91d7d #5: Enable merging subtitle-less. 2015-03-06 22:12:03 +01:00
Roel van Uden
2f1858cde7 #5: Support subtitle-less videos 2015-03-06 21:58:31 +01:00
Roel van Uden
a98ed223c6 #5: Support drama videos in regex 2015-03-06 21:50:31 +01:00
Roel van Uden
575569bd91 #4: Support spaces in Windows path 2015-03-06 21:41:02 +01:00
6 changed files with 16 additions and 13 deletions

View File

@@ -80,9 +80,9 @@ Download *Fairy Tail* to the current work directory:
crunchyroll http://www.crunchyroll.com/fairy-tail
Download *Fairy Tail* to `C:\Manga`:
Download *Fairy Tail* to `C:\Anime`:
crunchyroll --output C:\Manga http://www.crunchyroll.com/fairy-tail
crunchyroll --output C:\Anime http://www.crunchyroll.com/fairy-tail
#### Switches

View File

@@ -11,7 +11,7 @@
"type": "git",
"url": "git://github.com/Deathspike/crunchyroll.js.git"
},
"version": "1.1.1",
"version": "1.1.2",
"bin": {
"crunchyroll": "./bin/crunchyroll"
},

View File

@@ -51,7 +51,8 @@ function download(config: typings.IConfig, page: typings.IEpisodePage, player: t
downloadVideo(config, page, player, filePath, err => {
if (err) return done(err);
if (config.merge) return complete('Finished ' + fileName, now, done);
video.merge(config, player.video.file, filePath, err => {
var isSubtited = Boolean(player.subtitle);
video.merge(config, isSubtited, player.video.file, filePath, err => {
if (err) return done(err);
complete('Finished ' + fileName, now, done);
});
@@ -63,8 +64,9 @@ function download(config: typings.IConfig, page: typings.IEpisodePage, player: t
/**
* Saves the subtitles to disk.
*/
function downloadSubtitle(config: typings.IConfig, player: typings.IEpisodePlayer, filePath: string, done: (err: Error) => void) {
function downloadSubtitle(config: typings.IConfig, player: typings.IEpisodePlayer, filePath: string, done: (err?: Error) => void) {
var enc = player.subtitle;
if (!enc) return done();
subtitle.decode(enc.id, enc.iv, enc.data, (err, data) => {
if (err) return done(err);
var formats = subtitle.formats;
@@ -121,7 +123,7 @@ function scrapePage(config: typings.IConfig, address: string, done: (err: Error,
if (err) return done(err);
var $ = cheerio.load(result);
var swf = /^([^?]+)/.exec($('link[rel=video_src]').attr('href'));
var regexp = /Watch\s+(.+?)(?:\s+Season\s+([0-9]+))?\s+Episode\s+([0-9]+)/;
var regexp = /-\s+(?:Watch\s+)?(.+?)(?:\s+Season\s+([0-9]+))?(?:\s+-)?\s+Episode\s+([0-9]+)/;
var data = regexp.exec($('title').text());
if (!swf || !data) return done(new Error('Invalid page.'));
done(null, {
@@ -151,12 +153,13 @@ function scrapePlayer(config: typings.IConfig, address: string, id: number, done
}, (err: Error, player: typings.IEpisodePlayerConfig) => {
if (err) return done(err);
try {
var isSubtitled = Boolean(player['default:preload'].subtitle);
done(null, {
subtitle: {
subtitle: isSubtitled ? {
id: parseInt(player['default:preload'].subtitle.$.id, 10),
iv: player['default:preload'].subtitle.iv,
data: player['default:preload'].subtitle.data
},
} : null,
video: {
file: player['default:preload'].stream_info.file,
host: player['default:preload'].stream_info.host

View File

@@ -33,7 +33,7 @@ export interface IEpisodePage {
}
export interface IEpisodePlayer {
subtitle: {
subtitle?: {
id: number;
iv: string;
data: string;

View File

@@ -10,13 +10,13 @@ import typings = require('../typings');
/**
* Merges the subtitle and video files into a Matroska Multimedia Container.
*/
function main(config: typings.IConfig, rtmpInputPath: string, filePath: string, done: (err: Error) => void) {
function main(config: typings.IConfig, isSubtitled: boolean, rtmpInputPath: string, filePath: string, done: (err: Error) => void) {
var subtitlePath = filePath + '.' + (subtitle.formats[config.format] ? config.format : 'ass');
var videoPath = filePath + path.extname(rtmpInputPath);
childProcess.exec(command() + ' ' +
'-o "' + filePath + '.mkv" ' +
'"' + videoPath + '" ' +
'"' + subtitlePath + '"', {
(isSubtitled ? '"' + subtitlePath + '"' : ''), {
maxBuffer: Infinity
}, err => {
if (err) return done(err);
@@ -32,7 +32,7 @@ function main(config: typings.IConfig, rtmpInputPath: string, filePath: string,
*/
function command(): string {
if (os.platform() !== 'win32') return 'mkvmerge';
return path.join(__dirname, '../../bin/mkvmerge.exe');
return '"' + path.join(__dirname, '../../bin/mkvmerge.exe') + '"';
}
/**

View File

@@ -22,5 +22,5 @@ function main(rtmpUrl: string, rtmpInputPath: string, swfUrl: string, filePath:
*/
function command(): string {
if (os.platform() !== 'win32') return 'rtmpdump';
return path.join(__dirname, '../../bin/rtmpdump.exe');
return '"' + path.join(__dirname, '../../bin/rtmpdump.exe') + '"';
}