YouTube Video Download

By rossy! Last update Jan 10, 2013 — Installed 1,252,489 times.

illegal character in video title breaks the filename.

in
Subscribe to illegal character in video title breaks the filename. 4 posts, 4 voices



Eezy User
OperaWindows

i've noticed when i try to download a video where the video title has a non-alphanumeric character, the filename is not saved correctly.

example, http://www.youtube.com/watch?v=xK7FzjcqGpc

the title is, "Ultrabooks: What Are They?"

but the script saves it as, "What Are They.mp4".

in other scripts, they replace illegal characters with spaces, underscores, or just ignore them, but keep the full filename of the video title like, "Ultrabooks What Are They.mp4"

could you fix this? thanks!

 
Latebinder B... User
OperaX11

Yeah, this is hard when the title is made out of text direction change characters...no wait, copypasting the title still works. Make a case for a more difficult variant so it is worth doing? Surely there's a case for a batch preview/queue variant use? Timecode markup -in- titles? That of Hi10 PAL DVD 'Look Around You' videos? Watching with horizontal and time axes swapped?

 
QuHno User
OperaWindows

Quick and dirty fix for the ":" issue.
Replace the line:
var escapedTitle = tformatted.replace(/"/g, "-").replace(/%/g, "%25").replace(/=/g, "%3D").replace(/,/g, "%2C").replace(/&/g, "%26").replace(/#/g, "%23").replace(/\?/g, "%3F").replace(/\//g, "_").replace(/\\/g, "_").replace(/ /g, "+");

by
var escapedTitle = tformatted.replace(/\:/g, "--").replace(/"/g, "-").replace(/%/g, "%25").replace(/=/g, "%3D").replace(/,/g, "%2C").replace(/&/g, "%26").replace(/#/g, "%23").replace(/\?/g, "%3F").replace(/\//g, "_").replace(/\\/g, "_").replace(/ /g, "+");

That replaces the ":" by "--"

 
SBscripts Scriptwright
FirefoxWindows

It seems to me that the best fix to this is using the standard encodeURIComponent() function instead of this regex-based thing.

	//WAS:
	var escapedTitle = tformatted.replace(/"/g, "-").replace(/%/g, "%25").replace(/=/g, "%3D").replace(/,/g, "%2C").replace(/&/g, "%26").replace(/#/g, "%23").replace(/\?/g, "%3F").replace(/\//g, "_").replace(/\\/g, "_").replace(/ /g, "+");
	//IS:
	var escapedTitle = encodeURIComponent(tformatted);

I've incorporated it into my fixed version.