YouTube: fix some major issues on parsing video titles (#38, #39)

This commit is contained in:
Mort Yao 2012-12-12 02:32:26 +01:00
parent 311f5d1509
commit 44ce2e8f31
3 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,13 @@
Changelog
=========
0.3dev-20121212
---------------
*Date: 2012-12-12*
* YouTube: fix some major issues on parsing video titles.
0.3dev-20121210
---------------

View File

@ -4,10 +4,14 @@ __all__ = ['youtube_download', 'youtube_download_by_id']
from ..common import *
import json
def youtube_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False):
html = request.urlopen('http://www.youtube.com/watch?v=' + id).read().decode('utf-8')
title = r1(r'"title": "([^"]+)"', html)
html = unescape_html(html)
yt_player_config = json.loads(r1(r'yt.playerConfig = ([^\n]+);\n', html))
title = yt_player_config['args']['title']
title = unicodize(title)
title = parse.unquote(title)
title = escape_file_path(title)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
__version__ = '0.3dev-20121210'
__date__ = '2012-12-10'
__version__ = '0.3dev-20121212'
__date__ = '2012-12-12'