Re: Youtube.com 0.3 (Only requires Xyplorer now)
Posted: 22 Mar 2013 14:13
Version 0.3 is up!
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
- I'm studying regular expressions at the moment so I wrote everything in RegEx just for the sake of practice. I will look into the functions you mentioned to see where they could applyMarco wrote:
Llittle remark(s):
- there are replacement that are not strict regular expressions. I suspect a "standard" replace() / replacelist() could be better in terms of performance and readability. urldecode() also might be your friend (esp lines 19 to 27)
- you could write $Database with heredoc syntax, one entry per line, and then run a replace() to convert <crlf> to |. Reason: the database becomes way more readable and manageable, at least imho
- why you remove punctuation from video title?
Yes it does40k wrote:Hope that answers your questions
Code: Select all
Allowed characters in filenames
[cut]
In Win32 namespace, any UTF-16 code unit (case insensitive) except U+0000 (NUL) / (slash) \ (backslash) : (colon) * (asterisk) ? (Question mark) " (quote) < (less than) > (greater than) and | (pipe)
Code: Select all
[\x00/\\:\*\?"<>\|]
Yeah that's a downside but I believe that's an issue due to XYplorer itself and not the script. It's probably because XYplorer can't really multi-thread so while it's processing the script, it can't be allowed to do anything else?kotlmg wrote:i find this youtube download xyplorer script excellent.
while downloading the video, xyplorer is not being minimized as the script is running? can we do download videos on background using this script, so that xyplorer's minimize, maximize and other options are available to the user.
Enternal wrote:Yeah that's a downside but I believe that's an issue due to XYplorer itself and not the script. It's probably because XYplorer can't really multi-thread so while it's processing the script, it can't be allowed to do anything else?kotlmg wrote:i find this youtube download xyplorer script excellent.
while downloading the video, xyplorer is not being minimized as the script is running? can we do download videos on background using this script, so that xyplorer's minimize, maximize and other options are available to the user.
A possible solution to this problem could be to launch a separate instance of Xyplorer to run the download. I'm not sure if this can be down from inside a script but I'll look into it.kotlmg wrote:i find this youtube download xyplorer script excellent.
while downloading the video, xyplorer is not being minimized as the script is running? can we do download videos on background using this script, so that xyplorer's minimize, maximize and other options are available to the user.
Code: Select all
/****************************************************
*** YoutubeGet main functions // 40k ***
****************************************************/
"Main"
$Itag = "";
$Itags = "";
$Methode = inputselect(Choose methode for downloading:, "Paste from Clipboard|Type URL", , 2);
if ($Methode=="Paste from Clipboard"){
$YoutubeSource_All = readurl ("<clipboard>");
} else {
$destination = input("Type URL for download");
$YoutubeSource_All = readurl ($destination);
}
$RegEx ="<title>.+<\/title>";
$Title = regexmatches ("$YoutubeSource_All", "$RegEx", "", "0");
$RegEx ="<title>|<\/title>";
$Title = regexreplace ("$Title", "$RegEx", "", "0");
$RegEx = "[^:&;()\/ ]+\b";
$Title = regexmatches ("$Title", "$RegEx", " ", "0");
$RegEx = quote("url_encoded_fmt_stream_map"": ""[^""]*", "0");
$YoutubeSource_StreamMap = regexmatches ("$YoutubeSource_All", "$RegEx", "|", "0");
$RegEx = "\w+=[^,]+";
$YoutubeSource_QualityMap = regexmatches ("$YoutubeSource_StreamMap", "$RegEx", "|", "0");
$YoutubeSource_QualityMap = regexreplace ("$YoutubeSource_QualityMap", "\\u0026", "&", "0");
$YoutubeSource_QualityMap = regexreplace ("$YoutubeSource_QualityMap", "%26", "&", "0");
$YoutubeSource_QualityMap = regexreplace ("$YoutubeSource_QualityMap", "%3A", ":", "0");
$YoutubeSource_QualityMap = regexreplace ("$YoutubeSource_QualityMap", "%2F", "/", "0");
$YoutubeSource_QualityMap = regexreplace ("$YoutubeSource_QualityMap", "%3F", "?", "0");
$YoutubeSource_QualityMap = regexreplace ("$YoutubeSource_QualityMap", "%3D", "=", "0");
$YoutubeSource_QualityMap = regexreplace ("$YoutubeSource_QualityMap", "%25", "%", "0");
$YoutubeSource_QualityMap = regexreplace ("$YoutubeSource_QualityMap", "sig", "signature", "0");
$YoutubeSource_QualityMap = regexreplace ("$YoutubeSource_QualityMap", "url=", "", "0");
foreach ($Quality, $YoutubeSource_QualityMap, "|"){
$RegEx = "itag=\d{1,3}";
$Itags = regexmatches ("$Quality", "$RegEx", "@", "0");
$Itags = regexreplace ("$Itags", "itag=|@itag=\d+", "", "0");
$Itag = $Itag.$Itags."|";
}
$Database = "240p FLV 0.25+64 h263+mp3 @5|270p FLV 0.80+64 h263+mp3 @6|3GP 0.50+00 mpg4+aac @13|144p 3GP 0.05+24 mpg4+aac @17|270p MP4 0.50+96 h264+aac @18|720p MP4 2.90+192 h264+aac @22|360p FLV 0.50+128 h264+aac @34|480p FLV 1.00+128 h264+aac @35|240p 3GP 0.17+38 mpg4+aac @36|1080p MP4 4.30+192 h264+aac @37|3072p MP4 5.50+192 h264+aac @38|360p WebM 0.50+128 vp80+vob @43|480p WebM 1.00+128 vp80+vob @44|720p WebM 2.00+192 vp80+vob @45|1080p WebM 4.00+192 vp80+vob @46|360p MP4 (3D) 0.5+96 h264+aac @82|240p MP4(3D) 0.5+96 h264+aac @83|720p MP4 (3D) 2.90+152 h264+aac @84|MP4 520p (3D) 2.90+152 h264+aac @85|360p WebM (3D) 0.00+128 vp80+vob @100|WebM 360p (3D) 0.00+192 vp80+vob @101|720p WebM (3D) 0.00+192 vp80+vob @102|";
$MenuList = "";
foreach ($Tag, $Itag, "|"){
$RegEx = "[^|]*@$Tag";
$i = "";
$i = regexmatches ("$Database", "$RegEx", "o");
if ($i != "" && $Tag != ""){
$MenuList = $MenuList.$i."|";
}
}
$MenuSelection = inputselect ("Select Quality", "$MenuList", "|", "0", , , , );
$RegEx = "@\d{1,3}";
$Itag = regexmatches ("$MenuSelection", "$RegEx", "|", "0");
$Itag = regexreplace ("$Itag", "@", "", "0");
$RegEx = "[^|""]*itag=$Itag[^|""]*";
$URL = regexmatches ("$YoutubeSource_QualityMap", "$RegEx", "|", "0");
$RegEx = "[&]?(type|quality|itag|fallback_host)=[^&]+";
$URL = regexreplace ("$URL", "$RegEx", "", "0")."&itag=$Itag";
$RegEx = "[&]?http:[^&]+";
$HTTP = regexmatches ("$URL", "$RegEx", "", "0");
$URL = regexreplace ("$URL", "$RegEx", "", "0");
$HTTP = regexreplace ("$HTTP", "&", "", "0");
$URL = $HTTP.$URL; // This is the playable URL. Can be used anywhere to access the video
writefile ("$Title".".mp4", readurl("$URL"), "o", "b");