Subversion Repositories yt_downloader

Compare Revisions

Regard whitespace Rev 8 → Rev 7

/trunk/youtube_functions.inc.phps
1,7 → 1,7
<?php
 
// ViaThinkSoft YouTube Downloader Functions 2.1
// Revision: 2021-07-15
// Revision: 2021-05-09
// Author: Daniel Marschall <www.daniel-marschall.de>
// Licensed under the terms of the Apache 2.0 License
 
49,8 → 49,6
$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'];
73,8 → 71,6
$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'];
89,8 → 85,6
$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']);
105,8 → 99,6
$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'];
121,8 → 113,6
$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'];
142,8 → 132,6
$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'];
172,8 → 160,6
$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'];
196,7 → 182,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];
}
 
218,7 → 204,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-07-15
// Revision: 2021-05-09
// 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 or username URL. Skipping\n");
fwrite(STDERR, "URL $channel_url is a valid YouTube channel oder 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 {