From d3f5f9f6b902fdc892fb5fda37a3e49359436487 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Wed, 6 Feb 2013 21:22:53 +0100 Subject: [PATCH 1/5] Fix login (Closes #658) --- youtube_dl/InfoExtractors.py | 55 +++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index ac3ecea92..3e098a12e 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -151,7 +151,7 @@ class YoutubeIE(InfoExtractor): (?(1).+)? # if we found the ID, everything can follow $""" _LANG_URL = r'http://www.youtube.com/?hl=en&persist_hl=1&gl=US&persist_gl=1&opt_out_ackd=1' - _LOGIN_URL = 'https://www.youtube.com/signup?next=/&gl=US&hl=en' + _LOGIN_URL = 'https://accounts.google.com/ServiceLogin' _AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en' _NEXT_URL_RE = r'[\?&]next_url=([^&]+)' _NETRC_MACHINE = 'youtube' @@ -320,19 +320,54 @@ class YoutubeIE(InfoExtractor): if username is None: return + request = compat_urllib_request.Request(self._LOGIN_URL) + try: + login_page = compat_urllib_request.urlopen(request).read().decode('utf-8') + except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: + self._downloader.to_stderr(u'WARNING: unable to fetch login page: %s' % compat_str(err)) + return + + galx = None + dsh = None + match = re.search(re.compile(r']* name="loginForm"', login_results) is not None: + if re.search(r'(?i)]* id="gaia_loginform"', login_results) is not None: self._downloader.to_stderr(u'WARNING: unable to log in: bad username or password') return except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: From da06e2daf847a085e6b578d95c7003460451c333 Mon Sep 17 00:00:00 2001 From: Osama Khalid Date: Fri, 8 Feb 2013 10:25:55 +0300 Subject: [PATCH 2/5] Add KeekIE() --- youtube_dl/InfoExtractors.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index 3e098a12e..2eef2a698 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -3944,6 +3944,30 @@ class EightTracksIE(InfoExtractor): next_url = 'http://8tracks.com/sets/%s/next?player=sm&mix_id=%s&format=jsonh&track_id=%s' % (session, mix_id, track_data['id']) return res +class KeekIE(InfoExtractor): + _VALID_URL = r'http://(?:www\.)?keek\.com/(?:!|\w+/keeks/)(?P\w+)' + IE_NAME = u'keek' + + def _real_extract(self, url): + m = re.match(self._VALID_URL, url) + video_id = m.group('videoID') + video_url = u'http://cdn.keek.com/keek/video/%s' % video_id + thumbnail = u'http://cdn.keek.com/keek/thumbnail/%s/w100/h75' % video_id + webpage = self._download_webpage(url, video_id) + m = re.search(r'[\s\n]+

(?P\w+)

', webpage) + uploader = m.group('uploader') + info = { + 'id':video_id, + 'url':video_url, + 'ext': 'mp4', + 'title': title, + 'thumbnail': thumbnail, + 'uploader': uploader + } + return [info] + def gen_extractors(): """ Return a list of an instance of every supported extractor. The order does matter; the first extractor matched is the one handling the URL. @@ -3990,6 +4014,7 @@ def gen_extractors(): UstreamIE(), RBMARadioIE(), EightTracksIE(), + KeekIE(), GenericIE() ] From f0877a445e29ff58a4d377c8a193efb8f7c9b8e8 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Fri, 8 Feb 2013 11:00:28 +0100 Subject: [PATCH 3/5] Add tests for keek --- test/tests.json | 10 ++++++++++ youtube_dl/InfoExtractors.py | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/test/tests.json b/test/tests.json index d2058c21f..5c46af2c8 100644 --- a/test/tests.json +++ b/test/tests.json @@ -276,5 +276,15 @@ } } ] + }, + { + "name": "Keek", + "url": "http://www.keek.com/ytdl/keeks/NODfbab", + "file": "NODfbab.mp4", + "md5": "9b0636f8c0f7614afa4ea5e4c6e57e83", + "info_dict": { + "title": "test chars: \"'/\\ä<>This is a test video for youtube-dl.For more information, contact phihag@phihag.de ." + } + } ] diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index 2eef2a698..ac69f82fe 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -3955,9 +3955,9 @@ class KeekIE(InfoExtractor): thumbnail = u'http://cdn.keek.com/keek/thumbnail/%s/w100/h75' % video_id webpage = self._download_webpage(url, video_id) m = re.search(r'[\s\n]+

(?P\w+)

', webpage) - uploader = m.group('uploader') + uploader = unescapeHTML(m.group('uploader')) info = { 'id':video_id, 'url':video_url, @@ -3965,7 +3965,7 @@ class KeekIE(InfoExtractor): 'title': title, 'thumbnail': thumbnail, 'uploader': uploader - } + } return [info] def gen_extractors(): From 6aabe82035b0c5eff8b1d343e08a484ff0c12e60 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Fri, 8 Feb 2013 11:01:09 +0100 Subject: [PATCH 4/5] Credit Osama Khalid for Keek support --- youtube_dl/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 0a1041862..abcb4f165 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -23,6 +23,7 @@ __authors__ = ( 'Dave Vasilevsky', 'Jaime Marquínez Ferrándiz', 'Jeff Crouse', + 'Osama Khalid', ) __license__ = 'Public Domain' From 906417c7c586218c5a61f9966ce7d67528f97b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20Mikul=C4=97nas?= Date: Sat, 9 Feb 2013 22:58:12 +0200 Subject: [PATCH 5/5] Fix delayed title display in --console-title With Python 3, the titlebar wouldn't get updated for a long time (due to stderr buffering), and when it did, the title would be shown as b'...' representation. --- youtube_dl/FileDownloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index 49b032a1b..4f51ed8b0 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -208,7 +208,7 @@ class FileDownloader(object): # already of type unicode() ctypes.windll.kernel32.SetConsoleTitleW(ctypes.c_wchar_p(message)) elif 'TERM' in os.environ: - sys.stderr.write('\033]0;%s\007' % message.encode(preferredencoding())) + self.to_screen('\033]0;%s\007' % message, skip_eol=True) def fixed_template(self): """Checks if the output template is fixed."""