Subversion Repositories yt_downloader

Compare Revisions

Regard whitespace Rev 7 → Rev 8

/trunk/youtube_functions.inc.phps
1,7 → 1,7
<?php
 
// ViaThinkSoft YouTube Downloader Functions 2.1
// Revision: 2021-05-09
// Revision: 2021-07-15
// Author: Daniel Marschall <www.daniel-marschall.de>
// Licensed under the terms of the Apache 2.0 License
 
49,6 → 49,8
$obj = json_decode($cont, true);
if (!$obj) return false;
 
if (!isset($obj['items'])) return false;
 
foreach ($obj['items'] as $item) {
if ($item['snippet']['resourceId']['kind'] == 'youtube#video') {
$title = $item['snippet']['title'];
71,6 → 73,8
$obj = json_decode($cont, true);
if (!$obj) return false;
 
if (!isset($obj['items'])) return false;
 
foreach ($obj['items'] as $item) {
if ($item['kind'] == 'youtube#channel') {
return $item['id'];
85,6 → 89,8
$obj = json_decode($cont, true);
if (!$obj) return false;
 
if (!isset($obj['items'])) return false;
 
foreach ($obj['items'] as $item) {
if ($item['kind'] == 'youtube#channel') {
return array($item['id'], $item['statistics']);
99,6 → 105,8
$obj = json_decode($cont, true);
if (!$obj) return false;
 
if (!isset($obj['items'])) return false; //totalResults could be 0
 
foreach ($obj['items'] as $item) {
if ($item['kind'] == 'youtube#channel') {
return $item['statistics'];
113,6 → 121,8
$obj = json_decode($cont, true);
if (!$obj) return false;
 
if (!isset($obj['items'])) return false;
 
foreach ($obj['items'] as $item) {
if ($item['kind'] == 'youtube#playlist') {
return $item['contentDetails'];
132,6 → 142,8
$obj = json_decode($cont, true);
if (!$obj) return false;
 
if (!isset($obj['items'])) return false;
 
foreach ($obj['items'] as $item) {
if ($item['id']['kind'] == 'youtube#video') {
$title = $item['snippet']['title'];
160,6 → 172,8
$obj = json_decode($cont, true);
if (!$obj) return false;
 
if (!isset($obj['items'])) return false;
 
foreach ($obj['items'] as $item) {
if ($item['id']['kind'] == 'youtube#video') {
$title = $item['snippet']['title'];
182,7 → 196,7
$m = null;
 
# Usual format
if (($vid === false) && (preg_match("@https{0,1}://(www\\.|)youtube\\.com/watch(.*)(&|\\?)v=([a-zA-Z0-9_-]{11})@ismU", $url, $m))) {
if (($vid === false) && (preg_match("@https{0,1}://(www\\.|)youtube\\.com/watch(.*)(/|&|\\?)v=([a-zA-Z0-9_-]{11})@ismU", $url, $m))) {
$vid = $m[4];
}
 
204,7 → 218,7
 
# Usual format
$m = null;
if (($pid === false) && (preg_match("@https{0,1}://(www\\.|)youtube\\.com/(.*)(&|\\?)list=(.+)&@ismU", $url.'&', $m))) {
if (($pid === false) && (preg_match("@https{0,1}://(www\\.|)youtube\\.com/(.*)(/|&|\\?)list=(.+)&@ismU", $url.'&', $m))) {
$pid = $m[4];
}
 
/trunk/ytdwn
2,7 → 2,7
<?php
 
// ViaThinkSoft YouTube Downloader Util 2.2
// Revision: 2021-05-09
// Revision: 2021-07-15
// Author: Daniel Marschall <www.daniel-marschall.de>
// Licensed under the terms of the Apache 2.0 License
//
270,7 → 270,7
$channel_url = parse_quoting($channel_url);
$channel_id = curl_to_cid($channel_url);
if (!$channel_id) {
fwrite(STDERR, "URL $channel_url is a valid YouTube channel oder username URL. Skipping\n");
fwrite(STDERR, "URL $channel_url is a valid YouTube channel or username URL. Skipping\n");
} else {
ytdwn_channel_id($channel_id, $search);
}
591,11 → 591,11
 
function curl_to_cid($channel_url) {
$m = null;
if (preg_match("@https{0,1}://(www\\.|)youtube\\.com/user/(.*)(&|\\?)@ismU", $channel_url.'&', $m)) {
if (preg_match("@https{0,1}://(www\\.|)youtube\\.com/user/(.*)(/|&|\\?)@ismU", $channel_url.'&', $m)) {
$username = $m[2];
$channel_id = yt_get_channel_id($username);
return $channel_id;
} else if (preg_match("@https{0,1}://(www\\.|)youtube\\.com/channel/(.*)(&|\\?)@ismU", $channel_url.'&', $m)) {
} else if (preg_match("@https{0,1}://(www\\.|)youtube\\.com/channel/(.*)(/|&|\\?)@ismU", $channel_url.'&', $m)) {
$channel_id = $m[2];
return $channel_id;
} else {