Subversion Repositories yt_downloader

Compare Revisions

Regard whitespace Rev 14 → Rev 13

/trunk/checksum_functions.inc.phps
File deleted
/trunk/README.md
1,5 → 1,5
 
# ViaThinkSoft YouTube Downloader Util 2.3
# ViaThinkSoft YouTube Downloader Util 2.2
 
## Syntax
 
13,8 → 13,6
[-h|--help] (shows help)
[-N|--no-mp3-tagtransfer] (disables transfer of video ID to MP3 ID tag)
(This feature requires the package "id3v2")
[-H|--checksumMode] (Which checksum files shall be written for new files.
Must be 'None', 'MD5', 'SFV', or 'MD5,SFV')
[-T|--default-template <t>] (Sets default filename template.)
(Default: '%(title)s-%(id)s.%(ext)s')
[-X|--extra-args <args>] (Additional arguments passed through)
/trunk/youtube_functions.inc.phps
1,6 → 1,6
<?php
 
// ViaThinkSoft YouTube Downloader Functions 2.3
// ViaThinkSoft YouTube Downloader Functions 2.1
// Revision: 2022-02-06
// Author: Daniel Marschall <www.daniel-marschall.de>
// Licensed under the terms of the Apache 2.0 License
/trunk/ytdwn
1,7 → 1,7
#!/usr/bin/php
<?php
 
// ViaThinkSoft YouTube Downloader Util 2.3
// ViaThinkSoft YouTube Downloader Util 2.2
// Revision: 2022-02-06
// Author: Daniel Marschall <www.daniel-marschall.de>
// Licensed under the terms of the Apache 2.0 License
21,7 → 21,6
putenv("LANG=de_DE.UTF-8"); // required if video titles contain non-ASCII symbols
 
require_once __DIR__ . '/youtube_functions.inc.phps';
require_once __DIR__ . '/checksum_functions.inc.phps';
 
// Check if we are running in command line
 
40,7 → 39,6
$type = 'v:';
$outputDir = '';
$alreadyDownloaded = '';
$checksumMode = 'none';
$failList = '';
$failTreshold = 3;
$rest_args = array();
89,15 → 87,6
array_shift($argv_bak);
if (count($rest_args) > 0) syntax_error("Invalid argument: ".$rest_args[0]);
$resultcache = $m[3];
} else if (preg_match('@^(/H|\-H|\-\-checksumMode)(\s+|=)(.*)$@s', $arg2, $m)) {
array_shift($argv_bak);
if (count($rest_args) > 0) syntax_error("Invalid argument: ".$rest_args[0]);
$checksumMode = $m[3];
if ((strtolower($checksumMode) != 'none')
&& (strtolower($checksumMode) != 'sfv')
&& (strtolower($checksumMode) != 'md5')
&& (strtolower($checksumMode) != 'sfv,md5')
&& (strtolower($checksumMode) != 'md5,sfv')) syntax_error("Checksum mode needs to be either 'None', 'MD5', 'SFV', or 'MD5,SFV'.");
} else if (preg_match('@^(/T|\-T|\-\-default-template)(\s+|=)(.*)$@s', $arg2, $m)) {
array_shift($argv_bak);
if (count($rest_args) > 0) syntax_error("Invalid argument: ".$rest_args[0]);
499,7 → 488,6
global $default_template;
global $failTreshold;
global $cookie_file;
global $checksumMode;
 
if (DOWNLOAD_SIMULATION_MODE) {
echo "SIMULATE download of video id $video_id as ".hf_type($type)." to "._getOutputDir()."\n";
544,21 → 532,9
try {
addto_alreadydownloaded_file($type, $video_id);
} catch(Exception $e) {
fwrite(STDERR, "Cannot add to 'already downloaded' file\n");
fwrite(STDERR, "Cannot add to already downloaded file\n");
}
}
 
// Now do the checksums
foreach (explode(',',$checksumMode) as $mode) {
$test = glob(rtrim(_getOutputDir(), '/').'/*-'.$video_id.'.*');
if (count($test) == 0) {
fwrite(STDERR, "Cannot determine output file name.\n");
}
$written_file = $test[0];
if (!cs_add_automatically($written_file, $mode)) {
fwrite(STDERR, "Could not write to '$mode' checksum file!\n");
}
}
} else {
fwrite(STDERR, "Error downloading $video_id! (Code $code)\n");
if (!empty(_getFailList())) {