Subversion Repositories yt_downloader

Rev

Rev 16 | Rev 18 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16 Rev 17
Line 1... Line 1...
1
#!/usr/bin/php
1
#!/usr/bin/php
2
<?php
2
<?php
3
 
3
 
4
// ViaThinkSoft YouTube Downloader Util 2.3.1
4
// ViaThinkSoft YouTube Downloader Util 2.3.1
5
// Revision: 2022-02-07
5
// Revision: 2022-03-24
6
// Author: Daniel Marschall <www.daniel-marschall.de>
6
// Author: Daniel Marschall <www.daniel-marschall.de>
7
// Licensed under the terms of the Apache 2.0 License
7
// Licensed under the terms of the Apache 2.0 License
8
//
8
//
9
// For syntax and other documentation, please read the file README.
9
// For syntax and other documentation, please read the file README.
10
 
10
 
Line 367... Line 367...
367
		if (!empty($search)) {
367
		if (!empty($search)) {
368
			$out[$key]['results'] = yt_channel_items($channel_id, $search);
368
			$out[$key]['results'] = yt_channel_items($channel_id, $search);
369
		} else {
369
		} else {
370
			$out[$key]['results'] = yt_channel_items($channel_id);
370
			$out[$key]['results'] = yt_channel_items($channel_id);
371
		}
371
		}
372
		if (!$out[$key]['results']) {
372
		if ($out[$key]['results'] === false) {
373
			fwrite(STDERR, "Cannot get result for channel with ID '$channel_id'\n");
373
			fwrite(STDERR, "Cannot get result for channel with ID '$channel_id'\n");
374
			return;
374
			return;
375
		}
375
		}
376
	} else {
376
	} else {
377
		if ($verbose) echo "Video count for channel is still $videocount, keep ".count($out[$key]['results'])." results.\n";
377
		if ($verbose) echo "Video count for channel is still $videocount, keep ".count($out[$key]['results'])." results.\n";
Line 385... Line 385...
385
		fwrite(STDERR, "Cannot write result cache\n");
385
		fwrite(STDERR, "Cannot write result cache\n");
386
	}
386
	}
387
 
387
 
388
	// Now download
388
	// Now download
389
 
389
 
390
	if (!$out[$key]['results']) {
390
	if ($out[$key]['results'] === false) {
391
		fwrite(STDERR, "Cannot get result for channel with ID '$channel_id'\n");
391
		fwrite(STDERR, "Cannot get result for channel with ID '$channel_id'\n");
392
		return;
392
		return;
393
	}
393
	}
394
	foreach ($out[$key]['results'] as list($id, $title)) {
394
	foreach ($out[$key]['results'] as list($id, $title)) {
395
		if ($verbose) echo "Downloading '$title' as ".hf_type($type)." ...\n";
395
		if ($verbose) echo "Downloading '$title' as ".hf_type($type)." ...\n";
Line 430... Line 430...
430
 
430
 
431
	if ($videocount_old != $videocount) { // Attention: This might not work if videos are deleted and added (= the count stays the same)
431
	if ($videocount_old != $videocount) { // Attention: This might not work if videos are deleted and added (= the count stays the same)
432
		if ($verbose && $use_cache) echo "Video count changed from $videocount_old to $videocount\n";
432
		if ($verbose && $use_cache) echo "Video count changed from $videocount_old to $videocount\n";
433
		$out[$key]['count'] = $videocount;
433
		$out[$key]['count'] = $videocount;
434
		$out[$key]['results'] = yt_playlist_items($playlist_id);
434
		$out[$key]['results'] = yt_playlist_items($playlist_id);
435
		if (!$out[$key]['results']) {
435
		if ($out[$key]['results'] === false) {
436
			fwrite(STDERR, "Cannot get result for playlist with ID '$playlist_id'\n");
436
			fwrite(STDERR, "Cannot get result for playlist with ID '$playlist_id'\n");
437
			return;
437
			return;
438
		}
438
		}
439
	} else {
439
	} else {
440
		if ($verbose) echo "Video count for playlist is still $videocount, keep ".count($out[$key]['results'])." results.\n";
440
		if ($verbose) echo "Video count for playlist is still $videocount, keep ".count($out[$key]['results'])." results.\n";
Line 448... Line 448...
448
		fwrite(STDERR, "Cannot write result cache\n");
448
		fwrite(STDERR, "Cannot write result cache\n");
449
	}
449
	}
450
 
450
 
451
	// Now download
451
	// Now download
452
 
452
 
453
	if (!$out[$key]['results']) {
453
	if ($out[$key]['results'] === false) {
454
		fwrite(STDERR, "Cannot get result for playlist with ID '$playlist_id'\n");
454
		fwrite(STDERR, "Cannot get result for playlist with ID '$playlist_id'\n");
455
		return;
455
		return;
456
	}
456
	}
457
	foreach ($out[$key]['results'] as list($id, $title)) {
457
	foreach ($out[$key]['results'] as list($id, $title)) {
458
		if ($verbose) echo "Downloading '$title' as ".hf_type($type)." ...\n";
458
		if ($verbose) echo "Downloading '$title' as ".hf_type($type)." ...\n";
Line 470... Line 470...
470
 
470
 
471
	$results = yt_search_items($search, $order, $maxresults);
471
	$results = yt_search_items($search, $order, $maxresults);
472
 
472
 
473
	// Now download
473
	// Now download
474
 
474
 
475
	if (!$results) {
475
	if ($results === false) {
476
		fwrite(STDERR, "Cannot get data for search '$search'\n");
476
		fwrite(STDERR, "Cannot get data for search '$search'\n");
477
		return;
477
		return;
478
	}
478
	}
479
	foreach ($results as list($id, $title)) {
479
	foreach ($results as list($id, $title)) {
480
		if ($verbose) echo "Downloading '$title' as ".hf_type($type)." ...\n";
480
		if ($verbose) echo "Downloading '$title' as ".hf_type($type)." ...\n";