Compare commits
75 Commits
2013.09.24
...
2013.10.06
Author | SHA1 | Date | |
---|---|---|---|
7e5e8306fd | |||
41e8bca4d0 | |||
f4aac741d5 | |||
226113c880 | |||
8932a66e49 | |||
79cfb46d42 | |||
00fcc17aee | |||
e94b783c74 | |||
97dae9ae07 | |||
c3fef636b5 | |||
46e28a84ca | |||
17ad2b3fb1 | |||
5e2a60db4a | |||
cd214418f6 | |||
ba2d9f213e | |||
7f8ae73a5d | |||
466880f531 | |||
9f1f6d2437 | |||
9e0f897f6b | |||
c0f6aa876f | |||
d93bdee9a6 | |||
f13d09332d | |||
2f5865cc6d | |||
deefc05b88 | |||
0d8cb1cc14 | |||
a90b9fd209 | |||
829493439a | |||
3cd022f6e6 | |||
abefd1f7c4 | |||
c21315f273 | |||
9ab1018b1a | |||
da0a5d2d6e | |||
ee6adb166c | |||
be8fe32c92 | |||
c38b1e776d | |||
4f8bf17f23 | |||
ca40186c75 | |||
a8c6b24155 | |||
bd8e5c7ca2 | |||
7c61bd36bb | |||
c54283824c | |||
52f15da2ca | |||
44d466559e | |||
05751eb047 | |||
f10503db67 | |||
adfeafe9e1 | |||
4c62a16f4f | |||
c0de39e6d4 | |||
fa55675593 | |||
d4d9920a26 | |||
47192f92d8 | |||
722076a123 | |||
bb4aa62cf7 | |||
843530568f | |||
138a5454b5 | |||
d279037036 | |||
46353f6783 | |||
70922df8b5 | |||
9c15e9de84 | |||
123c10608d | |||
0b7c2485b6 | |||
9abb32045a | |||
f490e77e77 | |||
2dc592991a | |||
0a60edcfa9 | |||
c53f9d30c8 | |||
509f398292 | |||
74bab3f0a4 | |||
8574862991 | |||
2de957c7e1 | |||
920de7a27d | |||
63efc427cd | |||
ce65fb6c76 | |||
4de1994b6e | |||
592882aa9f |
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,3 +25,4 @@ updates_key.pem
|
|||||||
*.mp4
|
*.mp4
|
||||||
*.part
|
*.part
|
||||||
test/testdata
|
test/testdata
|
||||||
|
.tox
|
||||||
|
@ -31,8 +31,9 @@ which means you can modify it, redistribute it or use it however you like.
|
|||||||
--proxy URL Use the specified HTTP/HTTPS proxy
|
--proxy URL Use the specified HTTP/HTTPS proxy
|
||||||
--no-check-certificate Suppress HTTPS certificate validation.
|
--no-check-certificate Suppress HTTPS certificate validation.
|
||||||
--cache-dir None Location in the filesystem where youtube-dl can
|
--cache-dir None Location in the filesystem where youtube-dl can
|
||||||
store downloaded information permanently.
|
store downloaded information permanently. By
|
||||||
~/.youtube-dl/cache by default
|
default $XDG_CACHE_HOME/youtube-dl or ~/.cache
|
||||||
|
/youtube-dl .
|
||||||
--no-cache-dir Disable filesystem caching
|
--no-cache-dir Disable filesystem caching
|
||||||
|
|
||||||
## Video Selection:
|
## Video Selection:
|
||||||
@ -50,6 +51,7 @@ which means you can modify it, redistribute it or use it however you like.
|
|||||||
--date DATE download only videos uploaded in this date
|
--date DATE download only videos uploaded in this date
|
||||||
--datebefore DATE download only videos uploaded before this date
|
--datebefore DATE download only videos uploaded before this date
|
||||||
--dateafter DATE download only videos uploaded after this date
|
--dateafter DATE download only videos uploaded after this date
|
||||||
|
--no-playlist download only the currently playing video
|
||||||
|
|
||||||
## Download Options:
|
## Download Options:
|
||||||
-r, --rate-limit LIMIT maximum download rate (e.g. 50k or 44.6m)
|
-r, --rate-limit LIMIT maximum download rate (e.g. 50k or 44.6m)
|
||||||
|
@ -1,116 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
# Generate youtube signature algorithm from test cases
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
tests = [
|
|
||||||
# 93 - vfl79wBKW 2013/07/20
|
|
||||||
(u"qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]}|:;?/>.<'`~\"€",
|
|
||||||
u".>/?;:|}][{=+-_)(*&^%$#@!MNBVCXZASDFGHJKLPOIUYTREWQ098765'321mnbvcxzasdfghjklpoiu"),
|
|
||||||
# 92 - vflQw-fB4 2013/07/17
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]}|:;?/>.<'`~\"",
|
|
||||||
"mrtyuioplkjhgfdsazxcvbnq1234567890QWERTY}IOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]\"|:;"),
|
|
||||||
# 91 - vfl79wBKW 2013/07/20 (sporadic)
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]}|:;?/>.<'`~",
|
|
||||||
"/?;:|}][{=+-_)(*&^%$#@!MNBVCXZASDFGHJKLPOIUYTREWQ09876543.1mnbvcxzasdfghjklpoiu"),
|
|
||||||
# 90
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]}|:;?/>.<'`",
|
|
||||||
"mrtyuioplkjhgfdsazxcvbne1234567890QWER[YUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={`]}|"),
|
|
||||||
# 89
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]}|:;?/>.<'",
|
|
||||||
"/?;:|}<[{=+-_)(*&^%$#@!MqBVCXZASDFGHJKLPOIUYTREWQ0987654321mnbvcxzasdfghjklpoiuyt"),
|
|
||||||
# 88 - vflapUV9V 2013/08/28
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]}|:;?/>.<",
|
|
||||||
"ioplkjhgfdsazxcvbnm12<4567890QWERTYUIOZLKJHGFDSAeXCVBNM!@#$%^&*()_-+={[]}|:;?/>.3"),
|
|
||||||
# 87
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$^&*()_-+={[]}|:;?/>.<",
|
|
||||||
"uioplkjhgfdsazxcvbnm1t34567890QWE2TYUIOPLKJHGFDSAZXCVeNM!@#$^&*()_-+={[]}|:;?/>.<"),
|
|
||||||
# 86 - vflHql6Pr 2013/09/24
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[|};?/>.<",
|
|
||||||
";}|[{=+-d)(*&^%$#@!MNBVCXZASDFGHJKLPOIUYT_EWQ0987654321mnbvcxzas/fghjklpoiuytrewq"),
|
|
||||||
# 85 - vflkuzxcs 2013/09/11
|
|
||||||
('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[',
|
|
||||||
'3456789a0cdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS[UVWXYZ!"#$%&\'()*+,-./:;<=>?@'),
|
|
||||||
# 84 - vflHql6Pr 2013/09/24 (sporadic)
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[};?>.<",
|
|
||||||
"}[{=+-_)g*&^%$#@!MNBVCXZASDFGHJKLPOIUYTRE(Q0987654321mnbvcxzasdf?hjklpoiuytrewq"),
|
|
||||||
# 83
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!#$%^&*()_+={[};?/>.<",
|
|
||||||
".>/?;}[{=+_)(*&^%<#!MNBVCXZASPFGHJKLwOIUYTREWQ0987654321mnbvcxzasdfghjklpoiuytreq"),
|
|
||||||
# 82 - vflGNjMhJ 2013/09/12
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKHGFDSAZXCVBNM!@#$%^&*(-+={[};?/>.<",
|
|
||||||
".>/?;}[<=+-(*&^%$#@!MNBVCXeASDFGHKLPOqUYTREWQ0987654321mnbvcxzasdfghjklpoiuytrIwZ"),
|
|
||||||
# 81 - vflLC8JvQ 2013/07/25
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKHGFDSAZXCVBNM!@#$%^&*(-+={[};?/>.",
|
|
||||||
"C>/?;}[{=+-(*&^%$#@!MNBVYXZASDFGHKLPOIU.TREWQ0q87659321mnbvcxzasdfghjkl4oiuytrewp"),
|
|
||||||
# 80 - vflZK4ZYR 2013/08/23 (sporadic)
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKHGFDSAZXCVBNM!@#$%^&*(-+={[};?/>",
|
|
||||||
"wertyuioplkjhgfdsaqxcvbnm1234567890QWERTYUIOPLKHGFDSAZXCVBNM!@#$%^&z(-+={[};?/>"),
|
|
||||||
# 79 - vflLC8JvQ 2013/07/25 (sporadic)
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKHGFDSAZXCVBNM!@#$%^&*(-+={[};?/",
|
|
||||||
"Z?;}[{=+-(*&^%$#@!MNBVCXRASDFGHKLPOIUYT/EWQ0q87659321mnbvcxzasdfghjkl4oiuytrewp"),
|
|
||||||
]
|
|
||||||
|
|
||||||
tests_age_gate = [
|
|
||||||
# 86 - vflqinMWD
|
|
||||||
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[|};?/>.<",
|
|
||||||
"ertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!/#$%^&*()_-+={[|};?@"),
|
|
||||||
]
|
|
||||||
|
|
||||||
def find_matching(wrong, right):
|
|
||||||
idxs = [wrong.index(c) for c in right]
|
|
||||||
return compress(idxs)
|
|
||||||
return ('s[%d]' % i for i in idxs)
|
|
||||||
|
|
||||||
def compress(idxs):
|
|
||||||
def _genslice(start, end, step):
|
|
||||||
starts = '' if start == 0 else str(start)
|
|
||||||
ends = ':%d' % (end+step)
|
|
||||||
steps = '' if step == 1 else (':%d' % step)
|
|
||||||
return 's[%s%s%s]' % (starts, ends, steps)
|
|
||||||
|
|
||||||
step = None
|
|
||||||
for i, prev in zip(idxs[1:], idxs[:-1]):
|
|
||||||
if step is not None:
|
|
||||||
if i - prev == step:
|
|
||||||
continue
|
|
||||||
yield _genslice(start, prev, step)
|
|
||||||
step = None
|
|
||||||
continue
|
|
||||||
if i - prev in [-1, 1]:
|
|
||||||
step = i - prev
|
|
||||||
start = prev
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
yield 's[%d]' % prev
|
|
||||||
if step is None:
|
|
||||||
yield 's[%d]' % i
|
|
||||||
else:
|
|
||||||
yield _genslice(start, i, step)
|
|
||||||
|
|
||||||
def _assert_compress(inp, exp):
|
|
||||||
res = list(compress(inp))
|
|
||||||
if res != exp:
|
|
||||||
print('Got %r, expected %r' % (res, exp))
|
|
||||||
assert res == exp
|
|
||||||
_assert_compress([0,2,4,6], ['s[0]', 's[2]', 's[4]', 's[6]'])
|
|
||||||
_assert_compress([0,1,2,4,6,7], ['s[:3]', 's[4]', 's[6:8]'])
|
|
||||||
_assert_compress([8,0,1,2,4,7,6,9], ['s[8]', 's[:3]', 's[4]', 's[7:5:-1]', 's[9]'])
|
|
||||||
|
|
||||||
def gen(wrong, right, indent):
|
|
||||||
code = ' + '.join(find_matching(wrong, right))
|
|
||||||
return 'if len(s) == %d:\n%s return %s\n' % (len(wrong), indent, code)
|
|
||||||
|
|
||||||
def genall(tests):
|
|
||||||
indent = ' ' * 8
|
|
||||||
return indent + (indent + 'el').join(gen(wrong, right, indent) for wrong,right in tests)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
print(genall(tests))
|
|
||||||
print(u' Age gate:')
|
|
||||||
print(genall(tests_age_gate))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
@ -1,6 +1,9 @@
|
|||||||
|
import errno
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import os.path
|
import os.path
|
||||||
|
import re
|
||||||
|
import types
|
||||||
|
|
||||||
import youtube_dl.extractor
|
import youtube_dl.extractor
|
||||||
from youtube_dl import YoutubeDL, YoutubeDLHandler
|
from youtube_dl import YoutubeDL, YoutubeDLHandler
|
||||||
@ -20,19 +23,41 @@ PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "para
|
|||||||
with io.open(PARAMETERS_FILE, encoding='utf-8') as pf:
|
with io.open(PARAMETERS_FILE, encoding='utf-8') as pf:
|
||||||
parameters = json.load(pf)
|
parameters = json.load(pf)
|
||||||
|
|
||||||
|
|
||||||
|
def try_rm(filename):
|
||||||
|
""" Remove a file if it exists """
|
||||||
|
try:
|
||||||
|
os.remove(filename)
|
||||||
|
except OSError as ose:
|
||||||
|
if ose.errno != errno.ENOENT:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
class FakeYDL(YoutubeDL):
|
class FakeYDL(YoutubeDL):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.result = []
|
|
||||||
# Different instances of the downloader can't share the same dictionary
|
# Different instances of the downloader can't share the same dictionary
|
||||||
# some test set the "sublang" parameter, which would break the md5 checks.
|
# some test set the "sublang" parameter, which would break the md5 checks.
|
||||||
self.params = dict(parameters)
|
params = dict(parameters)
|
||||||
def to_screen(self, s):
|
super(FakeYDL, self).__init__(params)
|
||||||
|
self.result = []
|
||||||
|
|
||||||
|
def to_screen(self, s, skip_eol=None):
|
||||||
print(s)
|
print(s)
|
||||||
|
|
||||||
def trouble(self, s, tb=None):
|
def trouble(self, s, tb=None):
|
||||||
raise Exception(s)
|
raise Exception(s)
|
||||||
|
|
||||||
def download(self, x):
|
def download(self, x):
|
||||||
self.result.append(x)
|
self.result.append(x)
|
||||||
|
|
||||||
|
def expect_warning(self, regex):
|
||||||
|
# Silence an expected warning matching a regex
|
||||||
|
old_report_warning = self.report_warning
|
||||||
|
def report_warning(self, message):
|
||||||
|
if re.match(regex, message): return
|
||||||
|
old_report_warning(message)
|
||||||
|
self.report_warning = types.MethodType(report_warning, self)
|
||||||
|
|
||||||
def get_testcases():
|
def get_testcases():
|
||||||
for ie in youtube_dl.extractor.gen_extractors():
|
for ie in youtube_dl.extractor.gen_extractors():
|
||||||
t = getattr(ie, '_TEST', None)
|
t = getattr(ie, '_TEST', None)
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
import json
|
|
||||||
import io
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
# Allow direct execution
|
# Allow direct execution
|
||||||
@ -45,15 +43,18 @@ class TestDailymotionSubtitles(unittest.TestCase):
|
|||||||
subtitles = self.getSubtitles()
|
subtitles = self.getSubtitles()
|
||||||
self.assertEqual(len(subtitles.keys()), 5)
|
self.assertEqual(len(subtitles.keys()), 5)
|
||||||
def test_list_subtitles(self):
|
def test_list_subtitles(self):
|
||||||
|
self.DL.expect_warning(u'Automatic Captions not supported by this server')
|
||||||
self.DL.params['listsubtitles'] = True
|
self.DL.params['listsubtitles'] = True
|
||||||
info_dict = self.getInfoDict()
|
info_dict = self.getInfoDict()
|
||||||
self.assertEqual(info_dict, None)
|
self.assertEqual(info_dict, None)
|
||||||
def test_automatic_captions(self):
|
def test_automatic_captions(self):
|
||||||
|
self.DL.expect_warning(u'Automatic Captions not supported by this server')
|
||||||
self.DL.params['writeautomaticsub'] = True
|
self.DL.params['writeautomaticsub'] = True
|
||||||
self.DL.params['subtitleslang'] = ['en']
|
self.DL.params['subtitleslang'] = ['en']
|
||||||
subtitles = self.getSubtitles()
|
subtitles = self.getSubtitles()
|
||||||
self.assertTrue(len(subtitles.keys()) == 0)
|
self.assertTrue(len(subtitles.keys()) == 0)
|
||||||
def test_nosubtitles(self):
|
def test_nosubtitles(self):
|
||||||
|
self.DL.expect_warning(u'video doesn\'t have subtitles')
|
||||||
self.url = 'http://www.dailymotion.com/video/x12u166_le-zapping-tele-star-du-08-aout-2013_tv'
|
self.url = 'http://www.dailymotion.com/video/x12u166_le-zapping-tele-star-du-08-aout-2013_tv'
|
||||||
self.DL.params['writesubtitles'] = True
|
self.DL.params['writesubtitles'] = True
|
||||||
self.DL.params['allsubtitles'] = True
|
self.DL.params['allsubtitles'] = True
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import errno
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
@ -28,14 +27,6 @@ opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, You
|
|||||||
compat_urllib_request.install_opener(opener)
|
compat_urllib_request.install_opener(opener)
|
||||||
socket.setdefaulttimeout(10)
|
socket.setdefaulttimeout(10)
|
||||||
|
|
||||||
def _try_rm(filename):
|
|
||||||
""" Remove a file if it exists """
|
|
||||||
try:
|
|
||||||
os.remove(filename)
|
|
||||||
except OSError as ose:
|
|
||||||
if ose.errno != errno.ENOENT:
|
|
||||||
raise
|
|
||||||
|
|
||||||
md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest()
|
md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
class YoutubeDL(youtube_dl.YoutubeDL):
|
class YoutubeDL(youtube_dl.YoutubeDL):
|
||||||
@ -54,7 +45,7 @@ def _file_md5(fn):
|
|||||||
with open(fn, 'rb') as f:
|
with open(fn, 'rb') as f:
|
||||||
return hashlib.md5(f.read()).hexdigest()
|
return hashlib.md5(f.read()).hexdigest()
|
||||||
|
|
||||||
from helper import get_testcases
|
from helper import get_testcases, try_rm
|
||||||
defs = get_testcases()
|
defs = get_testcases()
|
||||||
|
|
||||||
with io.open(PARAMETERS_FILE, encoding='utf-8') as pf:
|
with io.open(PARAMETERS_FILE, encoding='utf-8') as pf:
|
||||||
@ -97,9 +88,9 @@ def generator(test_case):
|
|||||||
|
|
||||||
test_cases = test_case.get('playlist', [test_case])
|
test_cases = test_case.get('playlist', [test_case])
|
||||||
for tc in test_cases:
|
for tc in test_cases:
|
||||||
_try_rm(tc['file'])
|
try_rm(tc['file'])
|
||||||
_try_rm(tc['file'] + '.part')
|
try_rm(tc['file'] + '.part')
|
||||||
_try_rm(tc['file'] + '.info.json')
|
try_rm(tc['file'] + '.info.json')
|
||||||
try:
|
try:
|
||||||
for retry in range(1, RETRIES + 1):
|
for retry in range(1, RETRIES + 1):
|
||||||
try:
|
try:
|
||||||
@ -145,9 +136,9 @@ def generator(test_case):
|
|||||||
self.assertTrue(key in info_dict.keys() and info_dict[key])
|
self.assertTrue(key in info_dict.keys() and info_dict[key])
|
||||||
finally:
|
finally:
|
||||||
for tc in test_cases:
|
for tc in test_cases:
|
||||||
_try_rm(tc['file'])
|
try_rm(tc['file'])
|
||||||
_try_rm(tc['file'] + '.part')
|
try_rm(tc['file'] + '.part')
|
||||||
_try_rm(tc['file'] + '.info.json')
|
try_rm(tc['file'] + '.info.json')
|
||||||
|
|
||||||
return test_template
|
return test_template
|
||||||
|
|
||||||
|
@ -27,6 +27,14 @@ class TestYoutubeLists(unittest.TestCase):
|
|||||||
ytie_results = [YoutubeIE()._extract_id(url['url']) for url in result['entries']]
|
ytie_results = [YoutubeIE()._extract_id(url['url']) for url in result['entries']]
|
||||||
self.assertEqual(ytie_results, [ 'bV9L5Ht9LgY', 'FXxLjLQi3Fg', 'tU3Bgo5qJZE'])
|
self.assertEqual(ytie_results, [ 'bV9L5Ht9LgY', 'FXxLjLQi3Fg', 'tU3Bgo5qJZE'])
|
||||||
|
|
||||||
|
def test_youtube_playlist_noplaylist(self):
|
||||||
|
dl = FakeYDL()
|
||||||
|
dl.params['noplaylist'] = True
|
||||||
|
ie = YoutubePlaylistIE(dl)
|
||||||
|
result = ie.extract('https://www.youtube.com/watch?v=FXxLjLQi3Fg&list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re')
|
||||||
|
self.assertEqual(result['_type'], 'url')
|
||||||
|
self.assertEqual(YoutubeIE()._extract_id(result['url']), 'FXxLjLQi3Fg')
|
||||||
|
|
||||||
def test_issue_673(self):
|
def test_issue_673(self):
|
||||||
dl = FakeYDL()
|
dl = FakeYDL()
|
||||||
ie = YoutubePlaylistIE(dl)
|
ie = YoutubePlaylistIE(dl)
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
import json
|
|
||||||
import io
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
# Allow direct execution
|
# Allow direct execution
|
||||||
@ -56,6 +54,7 @@ class TestYoutubeSubtitles(unittest.TestCase):
|
|||||||
subtitles = self.getSubtitles()
|
subtitles = self.getSubtitles()
|
||||||
self.assertEqual(md5(subtitles['en']), '356cdc577fde0c6783b9b822e7206ff7')
|
self.assertEqual(md5(subtitles['en']), '356cdc577fde0c6783b9b822e7206ff7')
|
||||||
def test_youtube_list_subtitles(self):
|
def test_youtube_list_subtitles(self):
|
||||||
|
self.DL.expect_warning(u'Video doesn\'t have automatic captions')
|
||||||
self.DL.params['listsubtitles'] = True
|
self.DL.params['listsubtitles'] = True
|
||||||
info_dict = self.getInfoDict()
|
info_dict = self.getInfoDict()
|
||||||
self.assertEqual(info_dict, None)
|
self.assertEqual(info_dict, None)
|
||||||
@ -66,6 +65,7 @@ class TestYoutubeSubtitles(unittest.TestCase):
|
|||||||
subtitles = self.getSubtitles()
|
subtitles = self.getSubtitles()
|
||||||
self.assertTrue(subtitles['it'] is not None)
|
self.assertTrue(subtitles['it'] is not None)
|
||||||
def test_youtube_nosubtitles(self):
|
def test_youtube_nosubtitles(self):
|
||||||
|
self.DL.expect_warning(u'video doesn\'t have subtitles')
|
||||||
self.url = 'sAjKT8FhjI8'
|
self.url = 'sAjKT8FhjI8'
|
||||||
self.DL.params['writesubtitles'] = True
|
self.DL.params['writesubtitles'] = True
|
||||||
self.DL.params['allsubtitles'] = True
|
self.DL.params['allsubtitles'] = True
|
||||||
|
5
tox.ini
Normal file
5
tox.ini
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[tox]
|
||||||
|
envlist = py26,py27,py33
|
||||||
|
[testenv]
|
||||||
|
deps = nose
|
||||||
|
commands = nosetests --with-coverage --cover-package=youtube_dl --cover-html --verbose test
|
@ -444,8 +444,11 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
|||||||
if information['ext'] != u'mp4':
|
if information['ext'] != u'mp4':
|
||||||
self._downloader.to_screen(u'[ffmpeg] Subtitles can only be embedded in mp4 files')
|
self._downloader.to_screen(u'[ffmpeg] Subtitles can only be embedded in mp4 files')
|
||||||
return True, information
|
return True, information
|
||||||
sub_langs = [key for key in information['subtitles']]
|
if not information.get('subtitles'):
|
||||||
|
self._downloader.to_screen(u'[ffmpeg] There aren\'t any subtitles to embed')
|
||||||
|
return True, information
|
||||||
|
|
||||||
|
sub_langs = [key for key in information['subtitles']]
|
||||||
filename = information['filepath']
|
filename = information['filepath']
|
||||||
input_files = [filename] + [subtitles_filename(filename, lang, self._subformat) for lang in sub_langs]
|
input_files = [filename] + [subtitles_filename(filename, lang, self._subformat) for lang in sub_langs]
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ class YoutubeDL(object):
|
|||||||
skip_download: Skip the actual download of the video file
|
skip_download: Skip the actual download of the video file
|
||||||
cachedir: Location of the cache files in the filesystem.
|
cachedir: Location of the cache files in the filesystem.
|
||||||
None to disable filesystem cache.
|
None to disable filesystem cache.
|
||||||
|
noplaylist: Download single video instead of a playlist if in doubt.
|
||||||
|
|
||||||
The following parameters are not used by YoutubeDL itself, they are used by
|
The following parameters are not used by YoutubeDL itself, they are used by
|
||||||
the FileDownloader:
|
the FileDownloader:
|
||||||
@ -545,11 +546,15 @@ class YoutubeDL(object):
|
|||||||
thumb_filename = filename.rpartition('.')[0] + u'.' + thumb_format
|
thumb_filename = filename.rpartition('.')[0] + u'.' + thumb_format
|
||||||
self.to_screen(u'[%s] %s: Downloading thumbnail ...' %
|
self.to_screen(u'[%s] %s: Downloading thumbnail ...' %
|
||||||
(info_dict['extractor'], info_dict['id']))
|
(info_dict['extractor'], info_dict['id']))
|
||||||
uf = compat_urllib_request.urlopen(info_dict['thumbnail'])
|
try:
|
||||||
with open(thumb_filename, 'wb') as thumbf:
|
uf = compat_urllib_request.urlopen(info_dict['thumbnail'])
|
||||||
shutil.copyfileobj(uf, thumbf)
|
with open(thumb_filename, 'wb') as thumbf:
|
||||||
self.to_screen(u'[%s] %s: Writing thumbnail to: %s' %
|
shutil.copyfileobj(uf, thumbf)
|
||||||
(info_dict['extractor'], info_dict['id'], thumb_filename))
|
self.to_screen(u'[%s] %s: Writing thumbnail to: %s' %
|
||||||
|
(info_dict['extractor'], info_dict['id'], thumb_filename))
|
||||||
|
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
||||||
|
self.report_warning(u'Unable to download thumbnail "%s": %s' %
|
||||||
|
(info_dict['thumbnail'], compat_str(err)))
|
||||||
|
|
||||||
if not self.params.get('skip_download', False):
|
if not self.params.get('skip_download', False):
|
||||||
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(filename)):
|
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(filename)):
|
||||||
|
@ -168,8 +168,8 @@ def parseOpts(overrideArguments=None):
|
|||||||
general.add_option('--proxy', dest='proxy', default=None, help='Use the specified HTTP/HTTPS proxy', metavar='URL')
|
general.add_option('--proxy', dest='proxy', default=None, help='Use the specified HTTP/HTTPS proxy', metavar='URL')
|
||||||
general.add_option('--no-check-certificate', action='store_true', dest='no_check_certificate', default=False, help='Suppress HTTPS certificate validation.')
|
general.add_option('--no-check-certificate', action='store_true', dest='no_check_certificate', default=False, help='Suppress HTTPS certificate validation.')
|
||||||
general.add_option(
|
general.add_option(
|
||||||
'--cache-dir', dest='cachedir', default=u'~/.youtube-dl/cache',
|
'--cache-dir', dest='cachedir', default=get_cachedir(),
|
||||||
help='Location in the filesystem where youtube-dl can store downloaded information permanently. %default by default')
|
help='Location in the filesystem where youtube-dl can store downloaded information permanently. By default $XDG_CACHE_HOME/youtube-dl or ~/.cache/youtube-dl .')
|
||||||
general.add_option(
|
general.add_option(
|
||||||
'--no-cache-dir', action='store_const', const=None, dest='cachedir',
|
'--no-cache-dir', action='store_const', const=None, dest='cachedir',
|
||||||
help='Disable filesystem caching')
|
help='Disable filesystem caching')
|
||||||
@ -187,6 +187,7 @@ def parseOpts(overrideArguments=None):
|
|||||||
selection.add_option('--date', metavar='DATE', dest='date', help='download only videos uploaded in this date', default=None)
|
selection.add_option('--date', metavar='DATE', dest='date', help='download only videos uploaded in this date', default=None)
|
||||||
selection.add_option('--datebefore', metavar='DATE', dest='datebefore', help='download only videos uploaded before this date', default=None)
|
selection.add_option('--datebefore', metavar='DATE', dest='datebefore', help='download only videos uploaded before this date', default=None)
|
||||||
selection.add_option('--dateafter', metavar='DATE', dest='dateafter', help='download only videos uploaded after this date', default=None)
|
selection.add_option('--dateafter', metavar='DATE', dest='dateafter', help='download only videos uploaded after this date', default=None)
|
||||||
|
selection.add_option('--no-playlist', action='store_true', dest='noplaylist', help='download only the currently playing video', default=False)
|
||||||
|
|
||||||
|
|
||||||
authentication.add_option('-u', '--username',
|
authentication.add_option('-u', '--username',
|
||||||
@ -369,9 +370,13 @@ def parseOpts(overrideArguments=None):
|
|||||||
else:
|
else:
|
||||||
xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
|
xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
|
||||||
if xdg_config_home:
|
if xdg_config_home:
|
||||||
userConfFile = os.path.join(xdg_config_home, 'youtube-dl.conf')
|
userConfFile = os.path.join(xdg_config_home, 'youtube-dl', 'config')
|
||||||
|
if not os.path.isfile(userConfFile):
|
||||||
|
userConfFile = os.path.join(xdg_config_home, 'youtube-dl.conf')
|
||||||
else:
|
else:
|
||||||
userConfFile = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
|
userConfFile = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl', 'config')
|
||||||
|
if not os.path.isfile(userConfFile):
|
||||||
|
userConfFile = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
|
||||||
systemConf = _readOptions('/etc/youtube-dl.conf')
|
systemConf = _readOptions('/etc/youtube-dl.conf')
|
||||||
userConf = _readOptions(userConfFile)
|
userConf = _readOptions(userConfFile)
|
||||||
commandLineConf = sys.argv[1:]
|
commandLineConf = sys.argv[1:]
|
||||||
@ -599,6 +604,7 @@ def _real_main(argv=None):
|
|||||||
'progress_with_newline': opts.progress_with_newline,
|
'progress_with_newline': opts.progress_with_newline,
|
||||||
'playliststart': opts.playliststart,
|
'playliststart': opts.playliststart,
|
||||||
'playlistend': opts.playlistend,
|
'playlistend': opts.playlistend,
|
||||||
|
'noplaylist': opts.noplaylist,
|
||||||
'logtostderr': opts.outtmpl == '-',
|
'logtostderr': opts.outtmpl == '-',
|
||||||
'consoletitle': opts.consoletitle,
|
'consoletitle': opts.consoletitle,
|
||||||
'nopart': opts.nopart,
|
'nopart': opts.nopart,
|
||||||
@ -658,7 +664,7 @@ def _real_main(argv=None):
|
|||||||
|
|
||||||
# Update version
|
# Update version
|
||||||
if opts.update_self:
|
if opts.update_self:
|
||||||
update_self(ydl.to_screen, opts.verbose, sys.argv[0])
|
update_self(ydl.to_screen, opts.verbose)
|
||||||
|
|
||||||
# Maybe do nothing
|
# Maybe do nothing
|
||||||
if len(all_urls) < 1:
|
if len(all_urls) < 1:
|
||||||
|
@ -117,6 +117,7 @@ from .veehd import VeeHDIE
|
|||||||
from .veoh import VeohIE
|
from .veoh import VeohIE
|
||||||
from .vevo import VevoIE
|
from .vevo import VevoIE
|
||||||
from .vice import ViceIE
|
from .vice import ViceIE
|
||||||
|
from .viddler import ViddlerIE
|
||||||
from .videofyme import VideofyMeIE
|
from .videofyme import VideofyMeIE
|
||||||
from .vimeo import VimeoIE, VimeoChannelIE
|
from .vimeo import VimeoIE, VimeoChannelIE
|
||||||
from .vine import VineIE
|
from .vine import VineIE
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import re
|
import re
|
||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
|
import json
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
compat_urlparse,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,10 +16,9 @@ class AppleTrailersIE(InfoExtractor):
|
|||||||
u"playlist": [
|
u"playlist": [
|
||||||
{
|
{
|
||||||
u"file": u"manofsteel-trailer4.mov",
|
u"file": u"manofsteel-trailer4.mov",
|
||||||
u"md5": u"11874af099d480cc09e103b189805d5f",
|
u"md5": u"d97a8e575432dbcb81b7c3acb741f8a8",
|
||||||
u"info_dict": {
|
u"info_dict": {
|
||||||
u"duration": 111,
|
u"duration": 111,
|
||||||
u"thumbnail": u"http://trailers.apple.com/trailers/wb/manofsteel/images/thumbnail_11624.jpg",
|
|
||||||
u"title": u"Trailer 4",
|
u"title": u"Trailer 4",
|
||||||
u"upload_date": u"20130523",
|
u"upload_date": u"20130523",
|
||||||
u"uploader_id": u"wb",
|
u"uploader_id": u"wb",
|
||||||
@ -25,10 +26,9 @@ class AppleTrailersIE(InfoExtractor):
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
u"file": u"manofsteel-trailer3.mov",
|
u"file": u"manofsteel-trailer3.mov",
|
||||||
u"md5": u"07a0a262aae5afe68120eed61137ab34",
|
u"md5": u"b8017b7131b721fb4e8d6f49e1df908c",
|
||||||
u"info_dict": {
|
u"info_dict": {
|
||||||
u"duration": 182,
|
u"duration": 182,
|
||||||
u"thumbnail": u"http://trailers.apple.com/trailers/wb/manofsteel/images/thumbnail_10793.jpg",
|
|
||||||
u"title": u"Trailer 3",
|
u"title": u"Trailer 3",
|
||||||
u"upload_date": u"20130417",
|
u"upload_date": u"20130417",
|
||||||
u"uploader_id": u"wb",
|
u"uploader_id": u"wb",
|
||||||
@ -36,10 +36,9 @@ class AppleTrailersIE(InfoExtractor):
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
u"file": u"manofsteel-trailer.mov",
|
u"file": u"manofsteel-trailer.mov",
|
||||||
u"md5": u"e401fde0813008e3307e54b6f384cff1",
|
u"md5": u"d0f1e1150989b9924679b441f3404d48",
|
||||||
u"info_dict": {
|
u"info_dict": {
|
||||||
u"duration": 148,
|
u"duration": 148,
|
||||||
u"thumbnail": u"http://trailers.apple.com/trailers/wb/manofsteel/images/thumbnail_8703.jpg",
|
|
||||||
u"title": u"Trailer",
|
u"title": u"Trailer",
|
||||||
u"upload_date": u"20121212",
|
u"upload_date": u"20121212",
|
||||||
u"uploader_id": u"wb",
|
u"uploader_id": u"wb",
|
||||||
@ -47,10 +46,9 @@ class AppleTrailersIE(InfoExtractor):
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
u"file": u"manofsteel-teaser.mov",
|
u"file": u"manofsteel-teaser.mov",
|
||||||
u"md5": u"76b392f2ae9e7c98b22913c10a639c97",
|
u"md5": u"5fe08795b943eb2e757fa95cb6def1cb",
|
||||||
u"info_dict": {
|
u"info_dict": {
|
||||||
u"duration": 93,
|
u"duration": 93,
|
||||||
u"thumbnail": u"http://trailers.apple.com/trailers/wb/manofsteel/images/thumbnail_6899.jpg",
|
|
||||||
u"title": u"Teaser",
|
u"title": u"Teaser",
|
||||||
u"upload_date": u"20120721",
|
u"upload_date": u"20120721",
|
||||||
u"uploader_id": u"wb",
|
u"uploader_id": u"wb",
|
||||||
@ -59,87 +57,61 @@ class AppleTrailersIE(InfoExtractor):
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_JSON_RE = r'iTunes.playURL\((.*?)\);'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
movie = mobj.group('movie')
|
movie = mobj.group('movie')
|
||||||
uploader_id = mobj.group('company')
|
uploader_id = mobj.group('company')
|
||||||
|
|
||||||
playlist_url = url.partition(u'?')[0] + u'/includes/playlists/web.inc'
|
playlist_url = compat_urlparse.urljoin(url, u'includes/playlists/itunes.inc')
|
||||||
playlist_snippet = self._download_webpage(playlist_url, movie)
|
playlist_snippet = self._download_webpage(playlist_url, movie)
|
||||||
playlist_cleaned = re.sub(r'(?s)<script>.*?</script>', u'', playlist_snippet)
|
playlist_cleaned = re.sub(r'(?s)<script[^<]*?>.*?</script>', u'', playlist_snippet)
|
||||||
|
playlist_cleaned = re.sub(r'<img ([^<]*?)>', r'<img \1/>', playlist_cleaned)
|
||||||
|
# The ' in the onClick attributes are not escaped, it couldn't be parsed
|
||||||
|
# with xml.etree.ElementTree.fromstring
|
||||||
|
# like: http://trailers.apple.com/trailers/wb/gravity/
|
||||||
|
def _clean_json(m):
|
||||||
|
return u'iTunes.playURL(%s);' % m.group(1).replace('\'', ''')
|
||||||
|
playlist_cleaned = re.sub(self._JSON_RE, _clean_json, playlist_cleaned)
|
||||||
playlist_html = u'<html>' + playlist_cleaned + u'</html>'
|
playlist_html = u'<html>' + playlist_cleaned + u'</html>'
|
||||||
|
|
||||||
size_cache = {}
|
|
||||||
|
|
||||||
doc = xml.etree.ElementTree.fromstring(playlist_html)
|
doc = xml.etree.ElementTree.fromstring(playlist_html)
|
||||||
playlist = []
|
playlist = []
|
||||||
for li in doc.findall('./div/ul/li'):
|
for li in doc.findall('./div/ul/li'):
|
||||||
title = li.find('.//h3').text
|
on_click = li.find('.//a').attrib['onClick']
|
||||||
|
trailer_info_json = self._search_regex(self._JSON_RE,
|
||||||
|
on_click, u'trailer info')
|
||||||
|
trailer_info = json.loads(trailer_info_json)
|
||||||
|
title = trailer_info['title']
|
||||||
video_id = movie + '-' + re.sub(r'[^a-zA-Z0-9]', '', title).lower()
|
video_id = movie + '-' + re.sub(r'[^a-zA-Z0-9]', '', title).lower()
|
||||||
thumbnail = li.find('.//img').attrib['src']
|
thumbnail = li.find('.//img').attrib['src']
|
||||||
|
upload_date = trailer_info['posted'].replace('-', '')
|
||||||
|
|
||||||
date_el = li.find('.//p')
|
runtime = trailer_info['runtime']
|
||||||
upload_date = None
|
m = re.search(r'(?P<minutes>[0-9]+):(?P<seconds>[0-9]{1,2})', runtime)
|
||||||
m = re.search(r':\s?(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/(?P<year>[0-9]{2})', date_el.text)
|
|
||||||
if m:
|
|
||||||
upload_date = u'20' + m.group('year') + m.group('month') + m.group('day')
|
|
||||||
runtime_el = date_el.find('./br')
|
|
||||||
m = re.search(r':\s?(?P<minutes>[0-9]+):(?P<seconds>[0-9]{1,2})', runtime_el.tail)
|
|
||||||
duration = None
|
duration = None
|
||||||
if m:
|
if m:
|
||||||
duration = 60 * int(m.group('minutes')) + int(m.group('seconds'))
|
duration = 60 * int(m.group('minutes')) + int(m.group('seconds'))
|
||||||
|
|
||||||
|
first_url = trailer_info['url']
|
||||||
|
trailer_id = first_url.split('/')[-1].rpartition('_')[0].lower()
|
||||||
|
settings_json_url = compat_urlparse.urljoin(url, 'includes/settings/%s.json' % trailer_id)
|
||||||
|
settings_json = self._download_webpage(settings_json_url, trailer_id, u'Downloading settings json')
|
||||||
|
settings = json.loads(settings_json)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for formats_el in li.findall('.//a'):
|
for format in settings['metadata']['sizes']:
|
||||||
if formats_el.attrib['class'] != 'OverlayPanel':
|
# The src is a file pointing to the real video file
|
||||||
continue
|
format_url = re.sub(r'_(\d*p.mov)', r'_h\1', format['src'])
|
||||||
target = formats_el.attrib['target']
|
formats.append({
|
||||||
|
'url': format_url,
|
||||||
format_code = formats_el.text
|
'ext': determine_ext(format_url),
|
||||||
if 'Automatic' in format_code:
|
'format': format['type'],
|
||||||
continue
|
'width': format['width'],
|
||||||
|
'height': int(format['height']),
|
||||||
size_q = formats_el.attrib['href']
|
})
|
||||||
size_id = size_q.rpartition('#videos-')[2]
|
formats = sorted(formats, key=lambda f: (f['height'], f['width']))
|
||||||
if size_id not in size_cache:
|
|
||||||
size_url = url + size_q
|
|
||||||
sizepage_html = self._download_webpage(
|
|
||||||
size_url, movie,
|
|
||||||
note=u'Downloading size info %s' % size_id,
|
|
||||||
errnote=u'Error while downloading size info %s' % size_id,
|
|
||||||
)
|
|
||||||
_doc = xml.etree.ElementTree.fromstring(sizepage_html)
|
|
||||||
size_cache[size_id] = _doc
|
|
||||||
|
|
||||||
sizepage_doc = size_cache[size_id]
|
|
||||||
links = sizepage_doc.findall('.//{http://www.w3.org/1999/xhtml}ul/{http://www.w3.org/1999/xhtml}li/{http://www.w3.org/1999/xhtml}a')
|
|
||||||
for vid_a in links:
|
|
||||||
href = vid_a.get('href')
|
|
||||||
if not href.endswith(target):
|
|
||||||
continue
|
|
||||||
detail_q = href.partition('#')[0]
|
|
||||||
detail_url = url + '/' + detail_q
|
|
||||||
|
|
||||||
m = re.match(r'includes/(?P<detail_id>[^/]+)/', detail_q)
|
|
||||||
detail_id = m.group('detail_id')
|
|
||||||
|
|
||||||
detail_html = self._download_webpage(
|
|
||||||
detail_url, movie,
|
|
||||||
note=u'Downloading detail %s %s' % (detail_id, size_id),
|
|
||||||
errnote=u'Error while downloading detail %s %s' % (detail_id, size_id)
|
|
||||||
)
|
|
||||||
detail_doc = xml.etree.ElementTree.fromstring(detail_html)
|
|
||||||
movie_link_el = detail_doc.find('.//{http://www.w3.org/1999/xhtml}a')
|
|
||||||
assert movie_link_el.get('class') == 'movieLink'
|
|
||||||
movie_link = movie_link_el.get('href').partition('?')[0].replace('_', '_h')
|
|
||||||
ext = determine_ext(movie_link)
|
|
||||||
assert ext == 'mov'
|
|
||||||
|
|
||||||
formats.append({
|
|
||||||
'format': format_code,
|
|
||||||
'ext': ext,
|
|
||||||
'url': movie_link,
|
|
||||||
})
|
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'_type': 'video',
|
'_type': 'video',
|
||||||
|
@ -115,7 +115,7 @@ class BlipTVIE(InfoExtractor):
|
|||||||
ext = umobj.group(1)
|
ext = umobj.group(1)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'id': data['item_id'],
|
'id': compat_str(data['item_id']),
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'uploader': data['display_name'],
|
'uploader': data['display_name'],
|
||||||
'upload_date': upload_date,
|
'upload_date': upload_date,
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
@ -7,15 +9,39 @@ from ..utils import (
|
|||||||
compat_urllib_parse,
|
compat_urllib_parse,
|
||||||
find_xpath_attr,
|
find_xpath_attr,
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
|
|
||||||
|
ExtractorError,
|
||||||
)
|
)
|
||||||
|
|
||||||
class BrightcoveIE(InfoExtractor):
|
class BrightcoveIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://.*brightcove\.com/(services|viewer).*\?(?P<query>.*)'
|
_VALID_URL = r'https?://.*brightcove\.com/(services|viewer).*\?(?P<query>.*)'
|
||||||
_FEDERATED_URL_TEMPLATE = 'http://c.brightcove.com/services/viewer/htmlFederated?%s'
|
_FEDERATED_URL_TEMPLATE = 'http://c.brightcove.com/services/viewer/htmlFederated?%s'
|
||||||
_PLAYLIST_URL_TEMPLATE = 'http://c.brightcove.com/services/json/experience/runtime/?command=get_programming_for_experience&playerKey=%s'
|
_PLAYLIST_URL_TEMPLATE = 'http://c.brightcove.com/services/json/experience/runtime/?command=get_programming_for_experience&playerKey=%s'
|
||||||
|
|
||||||
# There is a test for Brigtcove in GenericIE, that way we test both the download
|
_TESTS = [
|
||||||
# and the detection of videos, and we don't have to find an URL that is always valid
|
{
|
||||||
|
# From http://www.8tv.cat/8aldia/videos/xavier-sala-i-martin-aquesta-tarda-a-8-al-dia/
|
||||||
|
u'url': u'http://c.brightcove.com/services/viewer/htmlFederated?playerID=1654948606001&flashID=myExperience&%40videoPlayer=2371591881001',
|
||||||
|
u'file': u'2371591881001.mp4',
|
||||||
|
u'md5': u'9e80619e0a94663f0bdc849b4566af19',
|
||||||
|
u'note': u'Test Brightcove downloads and detection in GenericIE',
|
||||||
|
u'info_dict': {
|
||||||
|
u'title': u'Xavier Sala i Martín: “Un banc que no presta és un banc zombi que no serveix per a res”',
|
||||||
|
u'uploader': u'8TV',
|
||||||
|
u'description': u'md5:a950cc4285c43e44d763d036710cd9cd',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
# From http://medianetwork.oracle.com/video/player/1785452137001
|
||||||
|
u'url': u'http://c.brightcove.com/services/viewer/htmlFederated?playerID=1217746023001&flashID=myPlayer&%40videoPlayer=1785452137001',
|
||||||
|
u'file': u'1785452137001.flv',
|
||||||
|
u'info_dict': {
|
||||||
|
u'title': u'JVMLS 2012: Arrays 2.0 - Opportunities and Challenges',
|
||||||
|
u'description': u'John Rose speaks at the JVM Language Summit, August 1, 2012.',
|
||||||
|
u'uploader': u'Oracle',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _build_brighcove_url(cls, object_str):
|
def _build_brighcove_url(cls, object_str):
|
||||||
@ -23,6 +49,11 @@ class BrightcoveIE(InfoExtractor):
|
|||||||
Build a Brightcove url from a xml string containing
|
Build a Brightcove url from a xml string containing
|
||||||
<object class="BrightcoveExperience">{params}</object>
|
<object class="BrightcoveExperience">{params}</object>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Fix up some stupid HTML, see https://github.com/rg3/youtube-dl/issues/1553
|
||||||
|
object_str = re.sub(r'(<param name="[^"]+" value="[^"]+")>',
|
||||||
|
lambda m: m.group(1) + '/>', object_str)
|
||||||
|
|
||||||
object_doc = xml.etree.ElementTree.fromstring(object_str)
|
object_doc = xml.etree.ElementTree.fromstring(object_str)
|
||||||
assert u'BrightcoveExperience' in object_doc.attrib['class']
|
assert u'BrightcoveExperience' in object_doc.attrib['class']
|
||||||
params = {'flashID': object_doc.attrib['id'],
|
params = {'flashID': object_doc.attrib['id'],
|
||||||
@ -72,15 +103,27 @@ class BrightcoveIE(InfoExtractor):
|
|||||||
playlist_title=playlist_info['mediaCollectionDTO']['displayName'])
|
playlist_title=playlist_info['mediaCollectionDTO']['displayName'])
|
||||||
|
|
||||||
def _extract_video_info(self, video_info):
|
def _extract_video_info(self, video_info):
|
||||||
renditions = video_info['renditions']
|
info = {
|
||||||
renditions = sorted(renditions, key=lambda r: r['size'])
|
'id': video_info['id'],
|
||||||
best_format = renditions[-1]
|
'title': video_info['displayName'],
|
||||||
|
'description': video_info.get('shortDescription'),
|
||||||
|
'thumbnail': video_info.get('videoStillURL') or video_info.get('thumbnailURL'),
|
||||||
|
'uploader': video_info.get('publisherName'),
|
||||||
|
}
|
||||||
|
|
||||||
return {'id': video_info['id'],
|
renditions = video_info.get('renditions')
|
||||||
'title': video_info['displayName'],
|
if renditions:
|
||||||
'url': best_format['defaultURL'],
|
renditions = sorted(renditions, key=lambda r: r['size'])
|
||||||
|
best_format = renditions[-1]
|
||||||
|
info.update({
|
||||||
|
'url': best_format['defaultURL'],
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'description': video_info.get('shortDescription'),
|
})
|
||||||
'thumbnail': video_info.get('videoStillURL') or video_info.get('thumbnailURL'),
|
elif video_info.get('FLVFullLengthURL') is not None:
|
||||||
'uploader': video_info.get('publisherName'),
|
info.update({
|
||||||
}
|
'url': video_info['FLVFullLengthURL'],
|
||||||
|
'ext': 'flv',
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ExtractorError(u'Unable to extract video url for %s' % info['id'])
|
||||||
|
return info
|
||||||
|
@ -51,12 +51,12 @@ class ComedyCentralIE(InfoExtractor):
|
|||||||
'400': 'mp4',
|
'400': 'mp4',
|
||||||
}
|
}
|
||||||
_video_dimensions = {
|
_video_dimensions = {
|
||||||
'3500': '1280x720',
|
'3500': (1280, 720),
|
||||||
'2200': '960x540',
|
'2200': (960, 540),
|
||||||
'1700': '768x432',
|
'1700': (768, 432),
|
||||||
'1200': '640x360',
|
'1200': (640, 360),
|
||||||
'750': '512x288',
|
'750': (512, 288),
|
||||||
'400': '384x216',
|
'400': (384, 216),
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -64,11 +64,13 @@ class ComedyCentralIE(InfoExtractor):
|
|||||||
"""Receives a URL and returns True if suitable for this IE."""
|
"""Receives a URL and returns True if suitable for this IE."""
|
||||||
return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
|
return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
|
||||||
|
|
||||||
def _print_formats(self, formats):
|
@staticmethod
|
||||||
print('Available formats:')
|
def _transform_rtmp_url(rtmp_video_url):
|
||||||
for x in formats:
|
m = re.match(r'^rtmpe?://.*?/(?P<finalid>gsp.comedystor/.*)$', rtmp_video_url)
|
||||||
print('%s\t:\t%s\t[%s]' %(x, self._video_extensions.get(x, 'mp4'), self._video_dimensions.get(x, '???')))
|
if not m:
|
||||||
|
raise ExtractorError(u'Cannot transform RTMP url')
|
||||||
|
base = 'http://mtvnmobile.vo.llnwd.net/kip0/_pxn=1+_pxI0=Ripod-h264+_pxL0=undefined+_pxM0=+_pxK=18639+_pxE=mp4/44620/mtvnorigin/'
|
||||||
|
return base + m.group('finalid')
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url, re.VERBOSE)
|
mobj = re.match(self._VALID_URL, url, re.VERBOSE)
|
||||||
@ -155,40 +157,31 @@ class ComedyCentralIE(InfoExtractor):
|
|||||||
self._downloader.report_error(u'unable to download ' + mediaId + ': No videos found')
|
self._downloader.report_error(u'unable to download ' + mediaId + ': No videos found')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self._downloader.params.get('listformats', None):
|
formats = []
|
||||||
self._print_formats([i[0] for i in turls])
|
for format, rtmp_video_url in turls:
|
||||||
return
|
w, h = self._video_dimensions.get(format, (None, None))
|
||||||
|
formats.append({
|
||||||
# For now, just pick the highest bitrate
|
'url': self._transform_rtmp_url(rtmp_video_url),
|
||||||
format,rtmp_video_url = turls[-1]
|
'ext': self._video_extensions.get(format, 'mp4'),
|
||||||
|
'format_id': format,
|
||||||
# Get the format arg from the arg stream
|
'height': h,
|
||||||
req_format = self._downloader.params.get('format', None)
|
'width': w,
|
||||||
|
})
|
||||||
# Select format if we can find one
|
|
||||||
for f,v in turls:
|
|
||||||
if f == req_format:
|
|
||||||
format, rtmp_video_url = f, v
|
|
||||||
break
|
|
||||||
|
|
||||||
m = re.match(r'^rtmpe?://.*?/(?P<finalid>gsp.comedystor/.*)$', rtmp_video_url)
|
|
||||||
if not m:
|
|
||||||
raise ExtractorError(u'Cannot transform RTMP url')
|
|
||||||
base = 'http://mtvnmobile.vo.llnwd.net/kip0/_pxn=1+_pxI0=Ripod-h264+_pxL0=undefined+_pxM0=+_pxK=18639+_pxE=mp4/44620/mtvnorigin/'
|
|
||||||
video_url = base + m.group('finalid')
|
|
||||||
|
|
||||||
effTitle = showId + u'-' + epTitle + u' part ' + compat_str(partNum+1)
|
effTitle = showId + u'-' + epTitle + u' part ' + compat_str(partNum+1)
|
||||||
info = {
|
info = {
|
||||||
'id': shortMediaId,
|
'id': shortMediaId,
|
||||||
'url': video_url,
|
'formats': formats,
|
||||||
'uploader': showId,
|
'uploader': showId,
|
||||||
'upload_date': officialDate,
|
'upload_date': officialDate,
|
||||||
'title': effTitle,
|
'title': effTitle,
|
||||||
'ext': 'mp4',
|
|
||||||
'format': format,
|
|
||||||
'thumbnail': None,
|
'thumbnail': None,
|
||||||
'description': compat_str(officialTitle),
|
'description': compat_str(officialTitle),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: Remove when #980 has been merged
|
||||||
|
info.update(info['formats'][-1])
|
||||||
|
|
||||||
results.append(info)
|
results.append(info)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -35,6 +35,8 @@ class InfoExtractor(object):
|
|||||||
title: Video title, unescaped.
|
title: Video title, unescaped.
|
||||||
ext: Video filename extension.
|
ext: Video filename extension.
|
||||||
|
|
||||||
|
Instead of url and ext, formats can also specified.
|
||||||
|
|
||||||
The following fields are optional:
|
The following fields are optional:
|
||||||
|
|
||||||
format: The video format, defaults to ext (used for --get-format)
|
format: The video format, defaults to ext (used for --get-format)
|
||||||
@ -52,8 +54,19 @@ class InfoExtractor(object):
|
|||||||
view_count: How many users have watched the video on the platform.
|
view_count: How many users have watched the video on the platform.
|
||||||
urlhandle: [internal] The urlHandle to be used to download the file,
|
urlhandle: [internal] The urlHandle to be used to download the file,
|
||||||
like returned by urllib.request.urlopen
|
like returned by urllib.request.urlopen
|
||||||
|
formats: A list of dictionaries for each format available, it must
|
||||||
|
be ordered from worst to best quality. Potential fields:
|
||||||
|
* url Mandatory. The URL of the video file
|
||||||
|
* ext Will be calculated from url if missing
|
||||||
|
* format A human-readable description of the format
|
||||||
|
("mp4 container with h264/opus").
|
||||||
|
Calculated from width and height if missing.
|
||||||
|
* format_id A short description of the format
|
||||||
|
("mp4_h264_opus" or "19")
|
||||||
|
* width Width of the video, if known
|
||||||
|
* height Height of the video, if known
|
||||||
|
|
||||||
The fields should all be Unicode strings.
|
Unless mentioned otherwise, the fields should be Unicode strings.
|
||||||
|
|
||||||
Subclasses of this one should re-define the _real_initialize() and
|
Subclasses of this one should re-define the _real_initialize() and
|
||||||
_real_extract() methods and define a _VALID_URL regexp.
|
_real_extract() methods and define a _VALID_URL regexp.
|
||||||
|
@ -10,25 +10,49 @@ from ..utils import (
|
|||||||
compat_str,
|
compat_str,
|
||||||
get_element_by_attribute,
|
get_element_by_attribute,
|
||||||
get_element_by_id,
|
get_element_by_id,
|
||||||
|
orderedSet,
|
||||||
|
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class DailymotionBaseInfoExtractor(InfoExtractor):
|
||||||
|
@staticmethod
|
||||||
|
def _build_request(url):
|
||||||
|
"""Build a request with the family filter disabled"""
|
||||||
|
request = compat_urllib_request.Request(url)
|
||||||
|
request.add_header('Cookie', 'family_filter=off')
|
||||||
|
return request
|
||||||
|
|
||||||
class DailymotionIE(SubtitlesInfoExtractor):
|
class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
|
||||||
"""Information Extractor for Dailymotion"""
|
"""Information Extractor for Dailymotion"""
|
||||||
|
|
||||||
_VALID_URL = r'(?i)(?:https?://)?(?:www\.)?dailymotion\.[a-z]{2,3}/(?:embed/)?video/([^/]+)'
|
_VALID_URL = r'(?i)(?:https?://)?(?:www\.)?dailymotion\.[a-z]{2,3}/(?:embed/)?video/([^/]+)'
|
||||||
IE_NAME = u'dailymotion'
|
IE_NAME = u'dailymotion'
|
||||||
_TEST = {
|
_TESTS = [
|
||||||
u'url': u'http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech',
|
{
|
||||||
u'file': u'x33vw9.mp4',
|
u'url': u'http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech',
|
||||||
u'md5': u'392c4b85a60a90dc4792da41ce3144eb',
|
u'file': u'x33vw9.mp4',
|
||||||
u'info_dict': {
|
u'md5': u'392c4b85a60a90dc4792da41ce3144eb',
|
||||||
u"uploader": u"Amphora Alex and Van .",
|
u'info_dict': {
|
||||||
u"title": u"Tutoriel de Youtubeur\"DL DES VIDEO DE YOUTUBE\""
|
u"uploader": u"Amphora Alex and Van .",
|
||||||
}
|
u"title": u"Tutoriel de Youtubeur\"DL DES VIDEO DE YOUTUBE\""
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
# Vevo video
|
||||||
|
{
|
||||||
|
u'url': u'http://www.dailymotion.com/video/x149uew_katy-perry-roar-official_musi',
|
||||||
|
u'file': u'USUV71301934.mp4',
|
||||||
|
u'info_dict': {
|
||||||
|
u'title': u'Roar (Official)',
|
||||||
|
u'uploader': u'Katy Perry',
|
||||||
|
u'upload_date': u'20130905',
|
||||||
|
},
|
||||||
|
u'params': {
|
||||||
|
u'skip_download': True,
|
||||||
|
},
|
||||||
|
u'skip': u'VEVO is only available in some countries',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
# Extract id and simplified title from URL
|
# Extract id and simplified title from URL
|
||||||
@ -40,13 +64,21 @@ class DailymotionIE(SubtitlesInfoExtractor):
|
|||||||
url = 'http://www.dailymotion.com/video/%s' % video_id
|
url = 'http://www.dailymotion.com/video/%s' % video_id
|
||||||
|
|
||||||
# Retrieve video webpage to extract further information
|
# Retrieve video webpage to extract further information
|
||||||
request = compat_urllib_request.Request(url)
|
request = self._build_request(url)
|
||||||
request.add_header('Cookie', 'family_filter=off')
|
|
||||||
webpage = self._download_webpage(request, video_id)
|
webpage = self._download_webpage(request, video_id)
|
||||||
|
|
||||||
# Extract URL, uploader and title from webpage
|
# Extract URL, uploader and title from webpage
|
||||||
self.report_extraction(video_id)
|
self.report_extraction(video_id)
|
||||||
|
|
||||||
|
# It may just embed a vevo video:
|
||||||
|
m_vevo = re.search(
|
||||||
|
r'<link rel="video_src" href="[^"]*?vevo.com[^"]*?videoId=(?P<id>[\w]*)',
|
||||||
|
webpage)
|
||||||
|
if m_vevo is not None:
|
||||||
|
vevo_id = m_vevo.group('id')
|
||||||
|
self.to_screen(u'Vevo video detected: %s' % vevo_id)
|
||||||
|
return self.url_result(u'vevo:%s' % vevo_id, ie='Vevo')
|
||||||
|
|
||||||
video_uploader = self._search_regex([r'(?im)<span class="owner[^\"]+?">[^<]+?<a [^>]+?>([^<]+?)</a>',
|
video_uploader = self._search_regex([r'(?im)<span class="owner[^\"]+?">[^<]+?<a [^>]+?>([^<]+?)</a>',
|
||||||
# Looking for official user
|
# Looking for official user
|
||||||
r'<(?:span|a) .*?rel="author".*?>([^<]+?)</'],
|
r'<(?:span|a) .*?rel="author".*?>([^<]+?)</'],
|
||||||
@ -113,7 +145,7 @@ class DailymotionIE(SubtitlesInfoExtractor):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class DailymotionPlaylistIE(InfoExtractor):
|
class DailymotionPlaylistIE(DailymotionBaseInfoExtractor):
|
||||||
IE_NAME = u'dailymotion:playlist'
|
IE_NAME = u'dailymotion:playlist'
|
||||||
_VALID_URL = r'(?:https?://)?(?:www\.)?dailymotion\.[a-z]{2,3}/playlist/(?P<id>.+?)/'
|
_VALID_URL = r'(?:https?://)?(?:www\.)?dailymotion\.[a-z]{2,3}/playlist/(?P<id>.+?)/'
|
||||||
_MORE_PAGES_INDICATOR = r'<div class="next">.*?<a.*?href="/playlist/.+?".*?>.*?</a>.*?</div>'
|
_MORE_PAGES_INDICATOR = r'<div class="next">.*?<a.*?href="/playlist/.+?".*?>.*?</a>.*?</div>'
|
||||||
@ -122,16 +154,17 @@ class DailymotionPlaylistIE(InfoExtractor):
|
|||||||
def _extract_entries(self, id):
|
def _extract_entries(self, id):
|
||||||
video_ids = []
|
video_ids = []
|
||||||
for pagenum in itertools.count(1):
|
for pagenum in itertools.count(1):
|
||||||
webpage = self._download_webpage(self._PAGE_TEMPLATE % (id, pagenum),
|
request = self._build_request(self._PAGE_TEMPLATE % (id, pagenum))
|
||||||
|
webpage = self._download_webpage(request,
|
||||||
id, u'Downloading page %s' % pagenum)
|
id, u'Downloading page %s' % pagenum)
|
||||||
|
|
||||||
playlist_el = get_element_by_attribute(u'class', u'video_list', webpage)
|
playlist_el = get_element_by_attribute(u'class', u'video_list', webpage)
|
||||||
video_ids.extend(re.findall(r'data-id="(.+?)" data-ext-id', playlist_el))
|
video_ids.extend(re.findall(r'data-id="(.+?)"', playlist_el))
|
||||||
|
|
||||||
if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
|
if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
|
||||||
break
|
break
|
||||||
return [self.url_result('http://www.dailymotion.com/video/%s' % video_id, 'Dailymotion')
|
return [self.url_result('http://www.dailymotion.com/video/%s' % video_id, 'Dailymotion')
|
||||||
for video_id in video_ids]
|
for video_id in orderedSet(video_ids)]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
|
@ -9,7 +9,7 @@ from ..utils import (
|
|||||||
|
|
||||||
class FlickrIE(InfoExtractor):
|
class FlickrIE(InfoExtractor):
|
||||||
"""Information Extractor for Flickr videos"""
|
"""Information Extractor for Flickr videos"""
|
||||||
_VALID_URL = r'(?:https?://)?(?:www\.)?flickr\.com/photos/(?P<uploader_id>[\w\-_@]+)/(?P<id>\d+).*'
|
_VALID_URL = r'(?:https?://)?(?:www\.|secure\.)?flickr\.com/photos/(?P<uploader_id>[\w\-_@]+)/(?P<id>\d+).*'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
u'url': u'http://www.flickr.com/photos/forestwander-nature-pictures/5645318632/in/photostream/',
|
u'url': u'http://www.flickr.com/photos/forestwander-nature-pictures/5645318632/in/photostream/',
|
||||||
u'file': u'5645318632.mp4',
|
u'file': u'5645318632.mp4',
|
||||||
|
@ -70,7 +70,11 @@ class FranceTvInfoIE(FranceTVBaseInfoExtractor):
|
|||||||
|
|
||||||
class France2IE(FranceTVBaseInfoExtractor):
|
class France2IE(FranceTVBaseInfoExtractor):
|
||||||
IE_NAME = u'france2.fr'
|
IE_NAME = u'france2.fr'
|
||||||
_VALID_URL = r'https?://www\.france2\.fr/emissions/.*?/videos/(?P<id>\d+)'
|
_VALID_URL = r'''(?x)https?://www\.france2\.fr/
|
||||||
|
(?:
|
||||||
|
emissions/.*?/videos/(?P<id>\d+)
|
||||||
|
| emission/(?P<key>[^/?]+)
|
||||||
|
)'''
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
u'url': u'http://www.france2.fr/emissions/13h15-le-samedi-le-dimanche/videos/75540104',
|
u'url': u'http://www.france2.fr/emissions/13h15-le-samedi-le-dimanche/videos/75540104',
|
||||||
@ -86,12 +90,20 @@ class France2IE(FranceTVBaseInfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id = mobj.group('id')
|
if mobj.group('key'):
|
||||||
|
webpage = self._download_webpage(url, mobj.group('key'))
|
||||||
|
video_id = self._html_search_regex(
|
||||||
|
r'''(?x)<div\s+class="video-player">\s*
|
||||||
|
<a\s+href="http://videos.francetv.fr/video/([0-9]+)"\s+
|
||||||
|
class="francetv-video-player">''',
|
||||||
|
webpage, u'video ID')
|
||||||
|
else:
|
||||||
|
video_id = mobj.group('id')
|
||||||
return self._extract_video(video_id)
|
return self._extract_video(video_id)
|
||||||
|
|
||||||
|
|
||||||
class GenerationQuoiIE(InfoExtractor):
|
class GenerationQuoiIE(InfoExtractor):
|
||||||
IE_NAME = u'http://generation-quoi.france2.fr'
|
IE_NAME = u'france2.fr:generation-quoi'
|
||||||
_VALID_URL = r'https?://generation-quoi\.france2\.fr/portrait/(?P<name>.*)(\?|$)'
|
_VALID_URL = r'https?://generation-quoi\.france2\.fr/portrait/(?P<name>.*)(\?|$)'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
|
@ -29,17 +29,6 @@ class GenericIE(InfoExtractor):
|
|||||||
u"title": u"R\u00e9gis plante sa Jeep"
|
u"title": u"R\u00e9gis plante sa Jeep"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
u'url': u'http://www.8tv.cat/8aldia/videos/xavier-sala-i-martin-aquesta-tarda-a-8-al-dia/',
|
|
||||||
u'file': u'2371591881001.mp4',
|
|
||||||
u'md5': u'9e80619e0a94663f0bdc849b4566af19',
|
|
||||||
u'note': u'Test Brightcove downloads and detection in GenericIE',
|
|
||||||
u'info_dict': {
|
|
||||||
u'title': u'Xavier Sala i Martín: “Un banc que no presta és un banc zombi que no serveix per a res”',
|
|
||||||
u'uploader': u'8TV',
|
|
||||||
u'description': u'md5:a950cc4285c43e44d763d036710cd9cd',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def report_download_webpage(self, video_id):
|
def report_download_webpage(self, video_id):
|
||||||
|
@ -41,7 +41,8 @@ class GooglePlusIE(InfoExtractor):
|
|||||||
|
|
||||||
# Extract update date
|
# Extract update date
|
||||||
upload_date = self._html_search_regex(
|
upload_date = self._html_search_regex(
|
||||||
['title="Timestamp">(.*?)</a>', r'<a.+?class="g-M.+?>(.+?)</a>'],
|
r'''(?x)<a.+?class="o-T-s\s[^"]+"\s+style="display:\s*none"\s*>
|
||||||
|
([0-9]{4}-[0-9]{2}-[0-9]{2})</a>''',
|
||||||
webpage, u'upload date', fatal=False)
|
webpage, u'upload date', fatal=False)
|
||||||
if upload_date:
|
if upload_date:
|
||||||
# Convert timestring to a format suitable for filename
|
# Convert timestring to a format suitable for filename
|
||||||
|
@ -13,7 +13,7 @@ class IGNIE(InfoExtractor):
|
|||||||
Some videos of it.ign.com are also supported
|
Some videos of it.ign.com are also supported
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_VALID_URL = r'https?://.+?\.ign\.com/(?P<type>videos|show_videos|articles)(/.+)?/(?P<name_or_id>.+)'
|
_VALID_URL = r'https?://.+?\.ign\.com/(?P<type>videos|show_videos|articles|(?:[^/]*/feature))(/.+)?/(?P<name_or_id>.+)'
|
||||||
IE_NAME = u'ign.com'
|
IE_NAME = u'ign.com'
|
||||||
|
|
||||||
_CONFIG_URL_TEMPLATE = 'http://www.ign.com/videos/configs/id/%s.config'
|
_CONFIG_URL_TEMPLATE = 'http://www.ign.com/videos/configs/id/%s.config'
|
||||||
@ -21,15 +21,39 @@ class IGNIE(InfoExtractor):
|
|||||||
r'id="my_show_video">.*?<p>(.*?)</p>',
|
r'id="my_show_video">.*?<p>(.*?)</p>',
|
||||||
]
|
]
|
||||||
|
|
||||||
_TEST = {
|
_TESTS = [
|
||||||
u'url': u'http://www.ign.com/videos/2013/06/05/the-last-of-us-review',
|
{
|
||||||
u'file': u'8f862beef863986b2785559b9e1aa599.mp4',
|
u'url': u'http://www.ign.com/videos/2013/06/05/the-last-of-us-review',
|
||||||
u'md5': u'eac8bdc1890980122c3b66f14bdd02e9',
|
u'file': u'8f862beef863986b2785559b9e1aa599.mp4',
|
||||||
u'info_dict': {
|
u'md5': u'eac8bdc1890980122c3b66f14bdd02e9',
|
||||||
u'title': u'The Last of Us Review',
|
u'info_dict': {
|
||||||
u'description': u'md5:c8946d4260a4d43a00d5ae8ed998870c',
|
u'title': u'The Last of Us Review',
|
||||||
}
|
u'description': u'md5:c8946d4260a4d43a00d5ae8ed998870c',
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
u'url': u'http://me.ign.com/en/feature/15775/100-little-things-in-gta-5-that-will-blow-your-mind',
|
||||||
|
u'playlist': [
|
||||||
|
{
|
||||||
|
u'file': u'5ebbd138523268b93c9141af17bec937.mp4',
|
||||||
|
u'info_dict': {
|
||||||
|
u'title': u'GTA 5 Video Review',
|
||||||
|
u'description': u'Rockstar drops the mic on this generation of games. Watch our review of the masterly Grand Theft Auto V.',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
u'file': u'638672ee848ae4ff108df2a296418ee2.mp4',
|
||||||
|
u'info_dict': {
|
||||||
|
u'title': u'GTA 5\'s Twisted Beauty in Super Slow Motion',
|
||||||
|
u'description': u'The twisted beauty of GTA 5 in stunning slow motion.',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
u'params': {
|
||||||
|
u'skip_download': True,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
def _find_video_id(self, webpage):
|
def _find_video_id(self, webpage):
|
||||||
res_id = [r'data-video-id="(.+?)"',
|
res_id = [r'data-video-id="(.+?)"',
|
||||||
@ -46,6 +70,13 @@ class IGNIE(InfoExtractor):
|
|||||||
if page_type == 'articles':
|
if page_type == 'articles':
|
||||||
video_url = self._search_regex(r'var videoUrl = "(.+?)"', webpage, u'video url')
|
video_url = self._search_regex(r'var videoUrl = "(.+?)"', webpage, u'video url')
|
||||||
return self.url_result(video_url, ie='IGN')
|
return self.url_result(video_url, ie='IGN')
|
||||||
|
elif page_type != 'video':
|
||||||
|
multiple_urls = re.findall(
|
||||||
|
'<param name="flashvars" value="[^"]*?url=(https?://www\.ign\.com/videos/.*?)["&]',
|
||||||
|
webpage)
|
||||||
|
if multiple_urls:
|
||||||
|
return [self.url_result(u, ie='IGN') for u in multiple_urls]
|
||||||
|
|
||||||
video_id = self._find_video_id(webpage)
|
video_id = self._find_video_id(webpage)
|
||||||
result = self._get_video_info(video_id)
|
result = self._get_video_info(video_id)
|
||||||
description = self._html_search_regex(self._DESCRIPTION_RE,
|
description = self._html_search_regex(self._DESCRIPTION_RE,
|
||||||
@ -87,6 +118,9 @@ class OneUPIE(IGNIE):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Override IGN tests
|
||||||
|
_TESTS = []
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
id = mobj.group('name_or_id')
|
id = mobj.group('name_or_id')
|
||||||
|
@ -12,7 +12,7 @@ class JeuxVideoIE(InfoExtractor):
|
|||||||
_TEST = {
|
_TEST = {
|
||||||
u'url': u'http://www.jeuxvideo.com/reportages-videos-jeux/0004/00046170/tearaway-playstation-vita-gc-2013-tearaway-nous-presente-ses-papiers-d-identite-00115182.htm',
|
u'url': u'http://www.jeuxvideo.com/reportages-videos-jeux/0004/00046170/tearaway-playstation-vita-gc-2013-tearaway-nous-presente-ses-papiers-d-identite-00115182.htm',
|
||||||
u'file': u'5182.mp4',
|
u'file': u'5182.mp4',
|
||||||
u'md5': u'e0fdb0cd3ce98713ef9c1e1e025779d0',
|
u'md5': u'046e491afb32a8aaac1f44dd4ddd54ee',
|
||||||
u'info_dict': {
|
u'info_dict': {
|
||||||
u'title': u'GC 2013 : Tearaway nous présente ses papiers d\'identité',
|
u'title': u'GC 2013 : Tearaway nous présente ses papiers d\'identité',
|
||||||
u'description': u'Lorsque les développeurs de LittleBigPlanet proposent un nouveau titre, on ne peut que s\'attendre à un résultat original et fort attrayant.\n',
|
u'description': u'Lorsque les développeurs de LittleBigPlanet proposent un nouveau titre, on ne peut que s\'attendre à un résultat original et fort attrayant.\n',
|
||||||
|
@ -54,23 +54,26 @@ class MTVIE(InfoExtractor):
|
|||||||
def _get_thumbnail_url(self, uri, itemdoc):
|
def _get_thumbnail_url(self, uri, itemdoc):
|
||||||
return 'http://mtv.mtvnimages.com/uri/' + uri
|
return 'http://mtv.mtvnimages.com/uri/' + uri
|
||||||
|
|
||||||
def _extract_video_url(self, metadataXml):
|
def _extract_video_formats(self, metadataXml):
|
||||||
if '/error_country_block.swf' in metadataXml:
|
if '/error_country_block.swf' in metadataXml:
|
||||||
raise ExtractorError(u'This video is not available from your country.', expected=True)
|
raise ExtractorError(u'This video is not available from your country.', expected=True)
|
||||||
mdoc = xml.etree.ElementTree.fromstring(metadataXml.encode('utf-8'))
|
mdoc = xml.etree.ElementTree.fromstring(metadataXml.encode('utf-8'))
|
||||||
renditions = mdoc.findall('.//rendition')
|
renditions = mdoc.findall('.//rendition')
|
||||||
|
|
||||||
# For now, always pick the highest quality.
|
formats = []
|
||||||
rendition = renditions[-1]
|
for rendition in mdoc.findall('.//rendition'):
|
||||||
|
try:
|
||||||
try:
|
_, _, ext = rendition.attrib['type'].partition('/')
|
||||||
_,_,ext = rendition.attrib['type'].partition('/')
|
rtmp_video_url = rendition.find('./src').text
|
||||||
format = ext + '-' + rendition.attrib['width'] + 'x' + rendition.attrib['height'] + '_' + rendition.attrib['bitrate']
|
formats.append({'ext': ext,
|
||||||
rtmp_video_url = rendition.find('./src').text
|
'url': self._transform_rtmp_url(rtmp_video_url),
|
||||||
except KeyError:
|
'format_id': rendition.get('bitrate'),
|
||||||
raise ExtractorError('Invalid rendition field.')
|
'width': int(rendition.get('width')),
|
||||||
video_url = self._transform_rtmp_url(rtmp_video_url)
|
'height': int(rendition.get('height')),
|
||||||
return {'ext': ext, 'url': video_url, 'format': format}
|
})
|
||||||
|
except (KeyError, TypeError):
|
||||||
|
raise ExtractorError('Invalid rendition field.')
|
||||||
|
return formats
|
||||||
|
|
||||||
def _get_video_info(self, itemdoc):
|
def _get_video_info(self, itemdoc):
|
||||||
uri = itemdoc.find('guid').text
|
uri = itemdoc.find('guid').text
|
||||||
@ -81,19 +84,25 @@ class MTVIE(InfoExtractor):
|
|||||||
mediagen_url += '&acceptMethods=fms'
|
mediagen_url += '&acceptMethods=fms'
|
||||||
mediagen_page = self._download_webpage(mediagen_url, video_id,
|
mediagen_page = self._download_webpage(mediagen_url, video_id,
|
||||||
u'Downloading video urls')
|
u'Downloading video urls')
|
||||||
video_info = self._extract_video_url(mediagen_page)
|
|
||||||
|
|
||||||
description_node = itemdoc.find('description')
|
description_node = itemdoc.find('description')
|
||||||
if description_node is not None:
|
if description_node is not None:
|
||||||
description = description_node.text
|
description = description_node.text
|
||||||
else:
|
else:
|
||||||
description = None
|
description = None
|
||||||
video_info.update({'title': itemdoc.find('title').text,
|
|
||||||
'id': video_id,
|
info = {
|
||||||
'thumbnail': self._get_thumbnail_url(uri, itemdoc),
|
'title': itemdoc.find('title').text,
|
||||||
'description': description,
|
'formats': self._extract_video_formats(mediagen_page),
|
||||||
})
|
'id': video_id,
|
||||||
return video_info
|
'thumbnail': self._get_thumbnail_url(uri, itemdoc),
|
||||||
|
'description': description,
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: Remove when #980 has been merged
|
||||||
|
info.update(info['formats'][-1])
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
def _get_videos_info(self, uri):
|
def _get_videos_info(self, uri):
|
||||||
video_id = self._id_from_uri(uri)
|
video_id = self._id_from_uri(uri)
|
||||||
|
@ -14,24 +14,25 @@ class RedTubeIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self,url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
|
|
||||||
video_id = mobj.group('id')
|
video_id = mobj.group('id')
|
||||||
video_extension = 'mp4'
|
video_extension = 'mp4'
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
self.report_extraction(video_id)
|
self.report_extraction(video_id)
|
||||||
|
|
||||||
video_url = self._html_search_regex(r'<source src="(.+?)" type="video/mp4">',
|
video_url = self._html_search_regex(
|
||||||
webpage, u'video URL')
|
r'<source src="(.+?)" type="video/mp4">', webpage, u'video URL')
|
||||||
|
|
||||||
video_title = self._html_search_regex('<h1 class="videoTitle slidePanelMovable">(.+?)</h1>',
|
video_title = self._html_search_regex(
|
||||||
|
r'<h1 class="videoTitle slidePanelMovable">(.+?)</h1>',
|
||||||
webpage, u'title')
|
webpage, u'title')
|
||||||
|
|
||||||
return [{
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'ext': video_extension,
|
'ext': video_extension,
|
||||||
'title': video_title,
|
'title': video_title,
|
||||||
}]
|
}
|
||||||
|
@ -8,8 +8,8 @@ from ..utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
class RTLnowIE(InfoExtractor):
|
class RTLnowIE(InfoExtractor):
|
||||||
"""Information Extractor for RTL NOW, RTL2 NOW, SUPER RTL NOW and VOX NOW"""
|
"""Information Extractor for RTL NOW, RTL2 NOW, RTL NITRO, SUPER RTL NOW, VOX NOW and n-tv NOW"""
|
||||||
_VALID_URL = r'(?:http://)?(?P<url>(?P<base_url>rtl-now\.rtl\.de/|rtl2now\.rtl2\.de/|(?:www\.)?voxnow\.de/|(?:www\.)?superrtlnow\.de/)[a-zA-Z0-9-]+/[a-zA-Z0-9-]+\.php\?(?:container_id|film_id)=(?P<video_id>[0-9]+)&player=1(?:&season=[0-9]+)?(?:&.*)?)'
|
_VALID_URL = r'(?:http://)?(?P<url>(?P<base_url>rtl-now\.rtl\.de/|rtl2now\.rtl2\.de/|(?:www\.)?voxnow\.de/|(?:www\.)?rtlnitronow\.de/|(?:www\.)?superrtlnow\.de/|(?:www\.)?n-tvnow\.de/)[a-zA-Z0-9-]+/[a-zA-Z0-9-]+\.php\?(?:container_id|film_id)=(?P<video_id>[0-9]+)&player=1(?:&season=[0-9]+)?(?:&.*)?)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
u'url': u'http://rtl-now.rtl.de/ahornallee/folge-1.php?film_id=90419&player=1&season=1',
|
u'url': u'http://rtl-now.rtl.de/ahornallee/folge-1.php?film_id=90419&player=1&season=1',
|
||||||
u'file': u'90419.flv',
|
u'file': u'90419.flv',
|
||||||
@ -61,8 +61,35 @@ class RTLnowIE(InfoExtractor):
|
|||||||
u'params': {
|
u'params': {
|
||||||
u'skip_download': True,
|
u'skip_download': True,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
u'url': u'http://www.rtlnitronow.de/recht-ordnung/lebensmittelkontrolle-erlangenordnungsamt-berlin.php?film_id=127367&player=1&season=1',
|
||||||
|
u'file': u'127367.flv',
|
||||||
|
u'info_dict': {
|
||||||
|
u'upload_date': u'20130926',
|
||||||
|
u'title': u'Recht & Ordnung - Lebensmittelkontrolle Erlangen/Ordnungsamt...',
|
||||||
|
u'description': u'Lebensmittelkontrolle Erlangen/Ordnungsamt Berlin',
|
||||||
|
u'thumbnail': u'http://autoimg.static-fra.de/nitronow/344787/1500x1500/image2.jpg',
|
||||||
|
},
|
||||||
|
u'params': {
|
||||||
|
u'skip_download': True,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
u'url': u'http://www.n-tvnow.de/top-gear/episode-1-2013-01-01-00-00-00.php?film_id=124903&player=1&season=10',
|
||||||
|
u'file': u'124903.flv',
|
||||||
|
u'info_dict': {
|
||||||
|
u'upload_date': u'20130101',
|
||||||
|
u'title': u'Top Gear vom 01.01.2013',
|
||||||
|
u'description': u'Episode 1',
|
||||||
|
},
|
||||||
|
u'params': {
|
||||||
|
u'skip_download': True,
|
||||||
|
},
|
||||||
|
u'skip': u'Only works from Germany',
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
def _real_extract(self,url):
|
def _real_extract(self,url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
|
|
||||||
@ -79,20 +106,23 @@ class RTLnowIE(InfoExtractor):
|
|||||||
msg = clean_html(note_m.group(1))
|
msg = clean_html(note_m.group(1))
|
||||||
raise ExtractorError(msg)
|
raise ExtractorError(msg)
|
||||||
|
|
||||||
video_title = self._html_search_regex(r'<title>(?P<title>[^<]+)</title>',
|
video_title = self._html_search_regex(r'<title>(?P<title>[^<]+?)( \| [^<]*)?</title>',
|
||||||
webpage, u'title')
|
webpage, u'title')
|
||||||
playerdata_url = self._html_search_regex(r'\'playerdata\': \'(?P<playerdata_url>[^\']+)\'',
|
playerdata_url = self._html_search_regex(r'\'playerdata\': \'(?P<playerdata_url>[^\']+)\'',
|
||||||
webpage, u'playerdata_url')
|
webpage, u'playerdata_url')
|
||||||
|
|
||||||
playerdata = self._download_webpage(playerdata_url, video_id)
|
playerdata = self._download_webpage(playerdata_url, video_id)
|
||||||
mobj = re.search(r'<title><!\[CDATA\[(?P<description>.+?)\s+- (?:Sendung )?vom (?P<upload_date_d>[0-9]{2})\.(?P<upload_date_m>[0-9]{2})\.(?:(?P<upload_date_Y>[0-9]{4})|(?P<upload_date_y>[0-9]{2})) [0-9]{2}:[0-9]{2} Uhr\]\]></title>', playerdata)
|
mobj = re.search(r'<title><!\[CDATA\[(?P<description>.+?)(?:\s+- (?:Sendung )?vom (?P<upload_date_d>[0-9]{2})\.(?P<upload_date_m>[0-9]{2})\.(?:(?P<upload_date_Y>[0-9]{4})|(?P<upload_date_y>[0-9]{2})) [0-9]{2}:[0-9]{2} Uhr)?\]\]></title>', playerdata)
|
||||||
if mobj:
|
if mobj:
|
||||||
video_description = mobj.group(u'description')
|
video_description = mobj.group(u'description')
|
||||||
if mobj.group('upload_date_Y'):
|
if mobj.group('upload_date_Y'):
|
||||||
video_upload_date = mobj.group('upload_date_Y')
|
video_upload_date = mobj.group('upload_date_Y')
|
||||||
else:
|
elif mobj.group('upload_date_y'):
|
||||||
video_upload_date = u'20' + mobj.group('upload_date_y')
|
video_upload_date = u'20' + mobj.group('upload_date_y')
|
||||||
video_upload_date += mobj.group('upload_date_m')+mobj.group('upload_date_d')
|
else:
|
||||||
|
video_upload_date = None
|
||||||
|
if video_upload_date:
|
||||||
|
video_upload_date += mobj.group('upload_date_m')+mobj.group('upload_date_d')
|
||||||
else:
|
else:
|
||||||
video_description = None
|
video_description = None
|
||||||
video_upload_date = None
|
video_upload_date = None
|
||||||
|
@ -77,12 +77,20 @@ class TEDIE(InfoExtractor):
|
|||||||
|
|
||||||
thumbnail = self._search_regex(r'</span>[\s.]*</div>[\s.]*<img src="(.*?)"',
|
thumbnail = self._search_regex(r'</span>[\s.]*</div>[\s.]*<img src="(.*?)"',
|
||||||
webpage, 'thumbnail')
|
webpage, 'thumbnail')
|
||||||
|
formats = [{
|
||||||
|
'ext': 'mp4',
|
||||||
|
'url': stream['file'],
|
||||||
|
'format': stream['id']
|
||||||
|
} for stream in info['htmlStreams']]
|
||||||
info = {
|
info = {
|
||||||
'id': info['id'],
|
'id': info['id'],
|
||||||
'url': info['htmlStreams'][-1]['file'],
|
'title': title,
|
||||||
'ext': 'mp4',
|
'thumbnail': thumbnail,
|
||||||
'title': title,
|
'description': desc,
|
||||||
'thumbnail': thumbnail,
|
'formats': formats,
|
||||||
'description': desc,
|
}
|
||||||
}
|
|
||||||
|
# TODO: Remove when #980 has been merged
|
||||||
|
info.update(info['formats'][-1])
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
64
youtube_dl/extractor/viddler.py
Normal file
64
youtube_dl/extractor/viddler.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import json
|
||||||
|
import re
|
||||||
|
|
||||||
|
from .common import InfoExtractor
|
||||||
|
from ..utils import (
|
||||||
|
determine_ext,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ViddlerIE(InfoExtractor):
|
||||||
|
_VALID_URL = r'(?P<domain>https?://(?:www\.)?viddler.com)/(?:v|embed|player)/(?P<id>[0-9]+)'
|
||||||
|
_TEST = {
|
||||||
|
u"url": u"http://www.viddler.com/v/43903784",
|
||||||
|
u'file': u'43903784.mp4',
|
||||||
|
u'md5': u'fbbaedf7813e514eb7ca30410f439ac9',
|
||||||
|
u'info_dict': {
|
||||||
|
u"title": u"Video Made Easy",
|
||||||
|
u"uploader": u"viddler",
|
||||||
|
u"duration": 100.89,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
mobj = re.match(self._VALID_URL, url)
|
||||||
|
video_id = mobj.group('id')
|
||||||
|
|
||||||
|
embed_url = mobj.group('domain') + u'/embed/' + video_id
|
||||||
|
webpage = self._download_webpage(embed_url, video_id)
|
||||||
|
|
||||||
|
video_sources_code = self._search_regex(
|
||||||
|
r"(?ms)sources\s*:\s*(\{.*?\})", webpage, u'video URLs')
|
||||||
|
video_sources = json.loads(video_sources_code.replace("'", '"'))
|
||||||
|
|
||||||
|
formats = [{
|
||||||
|
'url': video_url,
|
||||||
|
'format': format_id,
|
||||||
|
} for video_url, format_id in video_sources.items()]
|
||||||
|
|
||||||
|
title = self._html_search_regex(
|
||||||
|
r"title\s*:\s*'([^']*)'", webpage, u'title')
|
||||||
|
uploader = self._html_search_regex(
|
||||||
|
r"authorName\s*:\s*'([^']*)'", webpage, u'uploader', fatal=False)
|
||||||
|
duration_s = self._html_search_regex(
|
||||||
|
r"duration\s*:\s*([0-9.]*)", webpage, u'duration', fatal=False)
|
||||||
|
duration = float(duration_s) if duration_s else None
|
||||||
|
thumbnail = self._html_search_regex(
|
||||||
|
r"thumbnail\s*:\s*'([^']*)'",
|
||||||
|
webpage, u'thumbnail', fatal=False)
|
||||||
|
|
||||||
|
info = {
|
||||||
|
'_type': 'video',
|
||||||
|
'id': video_id,
|
||||||
|
'title': title,
|
||||||
|
'thumbnail': thumbnail,
|
||||||
|
'uploader': uploader,
|
||||||
|
'duration': duration,
|
||||||
|
'formats': formats,
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: Remove when #980 has been merged
|
||||||
|
info['formats'][-1]['ext'] = determine_ext(info['formats'][-1]['url'])
|
||||||
|
info.update(info['formats'][-1])
|
||||||
|
|
||||||
|
return info
|
@ -1,4 +1,3 @@
|
|||||||
import datetime
|
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
@ -6,86 +5,89 @@ import re
|
|||||||
from .common import InfoExtractor, SearchInfoExtractor
|
from .common import InfoExtractor, SearchInfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
compat_urllib_parse,
|
compat_urllib_parse,
|
||||||
|
compat_urlparse,
|
||||||
ExtractorError,
|
determine_ext,
|
||||||
|
clean_html,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class YahooIE(InfoExtractor):
|
class YahooIE(InfoExtractor):
|
||||||
IE_DESC = u'Yahoo screen'
|
IE_DESC = u'Yahoo screen'
|
||||||
_VALID_URL = r'http://screen\.yahoo\.com/.*?-(?P<id>\d*?)\.html'
|
_VALID_URL = r'http://screen\.yahoo\.com/.*?-(?P<id>\d*?)\.html'
|
||||||
_TEST = {
|
_TESTS = [
|
||||||
u'url': u'http://screen.yahoo.com/julian-smith-travis-legg-watch-214727115.html',
|
{
|
||||||
u'file': u'214727115.flv',
|
u'url': u'http://screen.yahoo.com/julian-smith-travis-legg-watch-214727115.html',
|
||||||
u'md5': u'2e717f169c1be93d84d3794a00d4a325',
|
u'file': u'214727115.flv',
|
||||||
u'info_dict': {
|
u'info_dict': {
|
||||||
u"title": u"Julian Smith & Travis Legg Watch Julian Smith"
|
u'title': u'Julian Smith & Travis Legg Watch Julian Smith',
|
||||||
|
u'description': u'Julian and Travis watch Julian Smith',
|
||||||
|
},
|
||||||
|
u'params': {
|
||||||
|
# Requires rtmpdump
|
||||||
|
u'skip_download': True,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
u'skip': u'Requires rtmpdump'
|
{
|
||||||
}
|
u'url': u'http://screen.yahoo.com/wired/codefellas-s1-ep12-cougar-lies-103000935.html',
|
||||||
|
u'file': u'103000935.flv',
|
||||||
|
u'info_dict': {
|
||||||
|
u'title': u'Codefellas - The Cougar Lies with Spanish Moss',
|
||||||
|
u'description': u'Agent Topple\'s mustache does its dirty work, and Nicole brokers a deal for peace. But why is the NSA collecting millions of Instagram brunch photos? And if your waffles have nothing to hide, what are they so worried about?',
|
||||||
|
},
|
||||||
|
u'params': {
|
||||||
|
# Requires rtmpdump
|
||||||
|
u'skip_download': True,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
if mobj is None:
|
|
||||||
raise ExtractorError(u'Invalid URL: %s' % url)
|
|
||||||
video_id = mobj.group('id')
|
video_id = mobj.group('id')
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
m_id = re.search(r'YUI\.namespace\("Media"\)\.CONTENT_ID = "(?P<new_id>.+?)";', webpage)
|
|
||||||
|
|
||||||
if m_id is None:
|
items_json = self._search_regex(r'YVIDEO_INIT_ITEMS = ({.*?});$',
|
||||||
# TODO: Check which url parameters are required
|
webpage, u'items', flags=re.MULTILINE)
|
||||||
info_url = 'http://cosmos.bcst.yahoo.com/rest/v2/pops;lmsoverride=1;outputformat=mrss;cb=974419660;id=%s;rd=news.yahoo.com;datacontext=mdb;lg=KCa2IihxG3qE60vQ7HtyUy' % video_id
|
items = json.loads(items_json)
|
||||||
webpage = self._download_webpage(info_url, video_id, u'Downloading info webpage')
|
info = items['mediaItems']['query']['results']['mediaObj'][0]
|
||||||
info_re = r'''<title><!\[CDATA\[(?P<title>.*?)\]\]></title>.*
|
meta = info['meta']
|
||||||
<description><!\[CDATA\[(?P<description>.*?)\]\]></description>.*
|
|
||||||
<media:pubStart><!\[CDATA\[(?P<date>.*?)\ .*\]\]></media:pubStart>.*
|
|
||||||
<media:content\ medium="image"\ url="(?P<thumb>.*?)"\ name="LARGETHUMB"
|
|
||||||
'''
|
|
||||||
self.report_extraction(video_id)
|
|
||||||
m_info = re.search(info_re, webpage, re.VERBOSE|re.DOTALL)
|
|
||||||
if m_info is None:
|
|
||||||
raise ExtractorError(u'Unable to extract video info')
|
|
||||||
video_title = m_info.group('title')
|
|
||||||
video_description = m_info.group('description')
|
|
||||||
video_thumb = m_info.group('thumb')
|
|
||||||
video_date = m_info.group('date')
|
|
||||||
video_date = datetime.datetime.strptime(video_date, '%m/%d/%Y').strftime('%Y%m%d')
|
|
||||||
|
|
||||||
# TODO: Find a way to get mp4 videos
|
|
||||||
rest_url = 'http://cosmos.bcst.yahoo.com/rest/v2/pops;element=stream;outputformat=mrss;id=%s;lmsoverride=1;bw=375;dynamicstream=1;cb=83521105;tech=flv,mp4;rd=news.yahoo.com;datacontext=mdb;lg=KCa2IihxG3qE60vQ7HtyUy' % video_id
|
|
||||||
webpage = self._download_webpage(rest_url, video_id, u'Downloading video url webpage')
|
|
||||||
m_rest = re.search(r'<media:content url="(?P<url>.*?)" path="(?P<path>.*?)"', webpage)
|
|
||||||
video_url = m_rest.group('url')
|
|
||||||
video_path = m_rest.group('path')
|
|
||||||
if m_rest is None:
|
|
||||||
raise ExtractorError(u'Unable to extract video url')
|
|
||||||
|
|
||||||
else: # We have to use a different method if another id is defined
|
formats = []
|
||||||
long_id = m_id.group('new_id')
|
for s in info['streams']:
|
||||||
info_url = 'http://video.query.yahoo.com/v1/public/yql?q=SELECT%20*%20FROM%20yahoo.media.video.streams%20WHERE%20id%3D%22' + long_id + '%22%20AND%20format%3D%22mp4%2Cflv%22%20AND%20protocol%3D%22rtmp%2Chttp%22%20AND%20plrs%3D%2286Gj0vCaSzV_Iuf6hNylf2%22%20AND%20acctid%3D%22389%22%20AND%20plidl%3D%22%22%20AND%20pspid%3D%22792700001%22%20AND%20offnetwork%3D%22false%22%20AND%20site%3D%22ivy%22%20AND%20lang%3D%22en-US%22%20AND%20region%3D%22US%22%20AND%20override%3D%22none%22%3B&env=prod&format=json&callback=YUI.Env.JSONP.yui_3_8_1_1_1368368376830_335'
|
format_info = {
|
||||||
webpage = self._download_webpage(info_url, video_id, u'Downloading info json')
|
'width': s.get('width'),
|
||||||
json_str = re.search(r'YUI.Env.JSONP.yui.*?\((.*?)\);', webpage).group(1)
|
'height': s.get('height'),
|
||||||
info = json.loads(json_str)
|
'bitrate': s.get('bitrate'),
|
||||||
res = info[u'query'][u'results'][u'mediaObj'][0]
|
}
|
||||||
stream = res[u'streams'][0]
|
|
||||||
video_path = stream[u'path']
|
host = s['host']
|
||||||
video_url = stream[u'host']
|
path = s['path']
|
||||||
meta = res[u'meta']
|
if host.startswith('rtmp'):
|
||||||
video_title = meta[u'title']
|
format_info.update({
|
||||||
video_description = meta[u'description']
|
'url': host,
|
||||||
video_thumb = meta[u'thumbnail']
|
'play_path': path,
|
||||||
video_date = None # I can't find it
|
'ext': 'flv',
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
format_url = compat_urlparse.urljoin(host, path)
|
||||||
|
format_info['url'] = format_url
|
||||||
|
format_info['ext'] = determine_ext(format_url)
|
||||||
|
|
||||||
|
formats.append(format_info)
|
||||||
|
formats = sorted(formats, key=lambda f:(f['height'], f['width']))
|
||||||
|
|
||||||
|
info = {
|
||||||
|
'id': video_id,
|
||||||
|
'title': meta['title'],
|
||||||
|
'formats': formats,
|
||||||
|
'description': clean_html(meta['description']),
|
||||||
|
'thumbnail': meta['thumbnail'],
|
||||||
|
}
|
||||||
|
# TODO: Remove when #980 has been merged
|
||||||
|
info.update(formats[-1])
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
info_dict = {
|
|
||||||
'id': video_id,
|
|
||||||
'url': video_url,
|
|
||||||
'play_path': video_path,
|
|
||||||
'title':video_title,
|
|
||||||
'description': video_description,
|
|
||||||
'thumbnail': video_thumb,
|
|
||||||
'upload_date': video_date,
|
|
||||||
'ext': 'flv',
|
|
||||||
}
|
|
||||||
return info_dict
|
|
||||||
|
|
||||||
class YahooSearchIE(SearchInfoExtractor):
|
class YahooSearchIE(SearchInfoExtractor):
|
||||||
IE_DESC = u'Yahoo screen search'
|
IE_DESC = u'Yahoo screen search'
|
||||||
|
@ -23,9 +23,11 @@ from ..utils import (
|
|||||||
compat_urllib_error,
|
compat_urllib_error,
|
||||||
compat_urllib_parse,
|
compat_urllib_parse,
|
||||||
compat_urllib_request,
|
compat_urllib_request,
|
||||||
|
compat_urlparse,
|
||||||
compat_str,
|
compat_str,
|
||||||
|
|
||||||
clean_html,
|
clean_html,
|
||||||
|
get_cachedir,
|
||||||
get_element_by_id,
|
get_element_by_id,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
@ -361,7 +363,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
u"info_dict": {
|
u"info_dict": {
|
||||||
u"upload_date": u"20120506",
|
u"upload_date": u"20120506",
|
||||||
u"title": u"Icona Pop - I Love It (feat. Charli XCX) [OFFICIAL VIDEO]",
|
u"title": u"Icona Pop - I Love It (feat. Charli XCX) [OFFICIAL VIDEO]",
|
||||||
u"description": u"md5:bdac09887d209a4ed54b8f76b2bdaa8b",
|
u"description": u"md5:5b292926389560516e384ac437c0ec07",
|
||||||
u"uploader": u"Icona Pop",
|
u"uploader": u"Icona Pop",
|
||||||
u"uploader_id": u"IconaPop"
|
u"uploader_id": u"IconaPop"
|
||||||
}
|
}
|
||||||
@ -378,21 +380,6 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
u"uploader_id": u"justintimberlakeVEVO"
|
u"uploader_id": u"justintimberlakeVEVO"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
u'url': u'https://www.youtube.com/watch?v=TGi3HqYrWHE',
|
|
||||||
u'file': u'TGi3HqYrWHE.mp4',
|
|
||||||
u'note': u'm3u8 video',
|
|
||||||
u'info_dict': {
|
|
||||||
u'title': u'Triathlon - Men - London 2012 Olympic Games',
|
|
||||||
u'description': u'- Men - TR02 - Triathlon - 07 August 2012 - London 2012 Olympic Games',
|
|
||||||
u'uploader': u'olympic',
|
|
||||||
u'upload_date': u'20120807',
|
|
||||||
u'uploader_id': u'olympic',
|
|
||||||
},
|
|
||||||
u'params': {
|
|
||||||
u'skip_download': True,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -435,8 +422,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
# Read from filesystem cache
|
# Read from filesystem cache
|
||||||
func_id = '%s_%s_%d' % (player_type, player_id, slen)
|
func_id = '%s_%s_%d' % (player_type, player_id, slen)
|
||||||
assert os.path.basename(func_id) == func_id
|
assert os.path.basename(func_id) == func_id
|
||||||
cache_dir = self._downloader.params.get('cachedir',
|
cache_dir = get_cachedir(self._downloader.params)
|
||||||
u'~/.youtube-dl/cache')
|
|
||||||
|
|
||||||
cache_enabled = cache_dir is not None
|
cache_enabled = cache_dir is not None
|
||||||
if cache_enabled:
|
if cache_enabled:
|
||||||
@ -1051,12 +1037,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
|
|
||||||
if player_url is not None:
|
if player_url is not None:
|
||||||
try:
|
try:
|
||||||
if player_url not in self._player_cache:
|
player_id = (player_url, len(s))
|
||||||
|
if player_id not in self._player_cache:
|
||||||
func = self._extract_signature_function(
|
func = self._extract_signature_function(
|
||||||
video_id, player_url, len(s)
|
video_id, player_url, len(s)
|
||||||
)
|
)
|
||||||
self._player_cache[player_url] = func
|
self._player_cache[player_id] = func
|
||||||
func = self._player_cache[player_url]
|
func = self._player_cache[player_id]
|
||||||
if self._downloader.params.get('youtube_print_sig_code'):
|
if self._downloader.params.get('youtube_print_sig_code'):
|
||||||
self._print_sig_code(func, len(s))
|
self._print_sig_code(func, len(s))
|
||||||
return func(s)
|
return func(s)
|
||||||
@ -1067,6 +1054,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
|
|
||||||
self._downloader.report_warning(
|
self._downloader.report_warning(
|
||||||
u'Warning: Falling back to static signature algorithm')
|
u'Warning: Falling back to static signature algorithm')
|
||||||
|
|
||||||
return self._static_decrypt_signature(
|
return self._static_decrypt_signature(
|
||||||
s, video_id, player_url, age_gate)
|
s, video_id, player_url, age_gate)
|
||||||
|
|
||||||
@ -1098,9 +1086,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
elif len(s) == 84:
|
elif len(s) == 84:
|
||||||
return s[78:70:-1] + s[14] + s[69:37:-1] + s[70] + s[36:14:-1] + s[80] + s[:14][::-1]
|
return s[78:70:-1] + s[14] + s[69:37:-1] + s[70] + s[36:14:-1] + s[80] + s[:14][::-1]
|
||||||
elif len(s) == 83:
|
elif len(s) == 83:
|
||||||
return s[81:64:-1] + s[82] + s[63:52:-1] + s[45] + s[51:45:-1] + s[1] + s[44:1:-1] + s[0]
|
return s[80:63:-1] + s[0] + s[62:0:-1] + s[63]
|
||||||
elif len(s) == 82:
|
elif len(s) == 82:
|
||||||
return s[80:73:-1] + s[81] + s[72:54:-1] + s[2] + s[53:43:-1] + s[0] + s[42:2:-1] + s[43] + s[1] + s[54]
|
return s[80:37:-1] + s[7] + s[36:7:-1] + s[0] + s[6:0:-1] + s[37]
|
||||||
elif len(s) == 81:
|
elif len(s) == 81:
|
||||||
return s[56] + s[79:56:-1] + s[41] + s[55:41:-1] + s[80] + s[40:34:-1] + s[0] + s[33:29:-1] + s[34] + s[28:9:-1] + s[29] + s[8:0:-1] + s[9]
|
return s[56] + s[79:56:-1] + s[41] + s[55:41:-1] + s[80] + s[40:34:-1] + s[0] + s[33:29:-1] + s[34] + s[28:9:-1] + s[29] + s[8:0:-1] + s[9]
|
||||||
elif len(s) == 80:
|
elif len(s) == 80:
|
||||||
@ -1347,9 +1335,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
self._downloader.report_warning(u'unable to extract uploader nickname')
|
self._downloader.report_warning(u'unable to extract uploader nickname')
|
||||||
|
|
||||||
# title
|
# title
|
||||||
if 'title' not in video_info:
|
if 'title' in video_info:
|
||||||
raise ExtractorError(u'Unable to extract video title')
|
video_title = compat_urllib_parse.unquote_plus(video_info['title'][0])
|
||||||
video_title = compat_urllib_parse.unquote_plus(video_info['title'][0])
|
else:
|
||||||
|
self._downloader.report_warning(u'Unable to extract video title')
|
||||||
|
video_title = u'_'
|
||||||
|
|
||||||
# thumbnail image
|
# thumbnail image
|
||||||
# We try first to get a high quality image:
|
# We try first to get a high quality image:
|
||||||
@ -1359,7 +1349,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
video_thumbnail = m_thumb.group(1)
|
video_thumbnail = m_thumb.group(1)
|
||||||
elif 'thumbnail_url' not in video_info:
|
elif 'thumbnail_url' not in video_info:
|
||||||
self._downloader.report_warning(u'unable to extract video thumbnail')
|
self._downloader.report_warning(u'unable to extract video thumbnail')
|
||||||
video_thumbnail = ''
|
video_thumbnail = None
|
||||||
else: # don't panic if we can't find it
|
else: # don't panic if we can't find it
|
||||||
video_thumbnail = compat_urllib_parse.unquote_plus(video_info['thumbnail_url'][0])
|
video_thumbnail = compat_urllib_parse.unquote_plus(video_info['thumbnail_url'][0])
|
||||||
|
|
||||||
@ -1404,6 +1394,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
args = info['args']
|
args = info['args']
|
||||||
# Easy way to know if the 's' value is in url_encoded_fmt_stream_map
|
# Easy way to know if the 's' value is in url_encoded_fmt_stream_map
|
||||||
# this signatures are encrypted
|
# this signatures are encrypted
|
||||||
|
if 'url_encoded_fmt_stream_map' not in args:
|
||||||
|
raise ValueError(u'No stream_map present') # caught below
|
||||||
m_s = re.search(r'[&,]s=', args['url_encoded_fmt_stream_map'])
|
m_s = re.search(r'[&,]s=', args['url_encoded_fmt_stream_map'])
|
||||||
if m_s is not None:
|
if m_s is not None:
|
||||||
self.to_screen(u'%s: Encrypted signatures detected.' % video_id)
|
self.to_screen(u'%s: Encrypted signatures detected.' % video_id)
|
||||||
@ -1479,7 +1471,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||||||
return
|
return
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ExtractorError(u'no conn or url_encoded_fmt_stream_map information found in video info')
|
raise ExtractorError(u'no conn, hlsvp or url_encoded_fmt_stream_map information found in video info')
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for format_param, video_real_url in video_url_list:
|
for format_param, video_real_url in video_url_list:
|
||||||
@ -1537,9 +1529,19 @@ class YoutubePlaylistIE(InfoExtractor):
|
|||||||
mobj = re.match(self._VALID_URL, url, re.VERBOSE)
|
mobj = re.match(self._VALID_URL, url, re.VERBOSE)
|
||||||
if mobj is None:
|
if mobj is None:
|
||||||
raise ExtractorError(u'Invalid URL: %s' % url)
|
raise ExtractorError(u'Invalid URL: %s' % url)
|
||||||
|
playlist_id = mobj.group(1) or mobj.group(2)
|
||||||
|
|
||||||
|
# Check if it's a video-specific URL
|
||||||
|
query_dict = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
|
||||||
|
if 'v' in query_dict:
|
||||||
|
video_id = query_dict['v'][0]
|
||||||
|
if self._downloader.params.get('noplaylist'):
|
||||||
|
self.to_screen(u'Downloading just video %s because of --no-playlist' % video_id)
|
||||||
|
return self.url_result('https://www.youtube.com/watch?v=' + video_id, 'Youtube')
|
||||||
|
else:
|
||||||
|
self.to_screen(u'Downloading playlist PL%s - add --no-playlist to just download video %s' % (playlist_id, video_id))
|
||||||
|
|
||||||
# Download playlist videos from API
|
# Download playlist videos from API
|
||||||
playlist_id = mobj.group(1) or mobj.group(2)
|
|
||||||
videos = []
|
videos = []
|
||||||
|
|
||||||
for page_num in itertools.count(1):
|
for page_num in itertools.count(1):
|
||||||
|
@ -2,16 +2,14 @@ import re
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
determine_ext,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
unescapeHTML,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ZDFIE(InfoExtractor):
|
class ZDFIE(InfoExtractor):
|
||||||
_VALID_URL = r'^http://www\.zdf\.de\/ZDFmediathek\/(.*beitrag\/video\/)(?P<video_id>[^/\?]+)(?:\?.*)?'
|
_VALID_URL = r'^http://www\.zdf\.de\/ZDFmediathek(?P<hash>#)?\/(.*beitrag\/video\/)(?P<video_id>[^/\?]+)(?:\?.*)?'
|
||||||
_TITLE = r'<h1(?: class="beitragHeadline")?>(?P<title>.*)</h1>'
|
|
||||||
_MEDIA_STREAM = r'<a href="(?P<video_url>.+(?P<media_type>.streaming).+/zdf/(?P<quality>[^\/]+)/[^"]*)".+class="play".+>'
|
_MEDIA_STREAM = r'<a href="(?P<video_url>.+(?P<media_type>.streaming).+/zdf/(?P<quality>[^\/]+)/[^"]*)".+class="play".+>'
|
||||||
_MMS_STREAM = r'href="(?P<video_url>mms://[^"]*)"'
|
|
||||||
_RTSP_STREAM = r'(?P<video_url>rtsp://[^"]*.mp4)'
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
@ -19,6 +17,9 @@ class ZDFIE(InfoExtractor):
|
|||||||
raise ExtractorError(u'Invalid URL: %s' % url)
|
raise ExtractorError(u'Invalid URL: %s' % url)
|
||||||
video_id = mobj.group('video_id')
|
video_id = mobj.group('video_id')
|
||||||
|
|
||||||
|
if mobj.group('hash'):
|
||||||
|
url = url.replace(u'#', u'', 1)
|
||||||
|
|
||||||
html = self._download_webpage(url, video_id)
|
html = self._download_webpage(url, video_id)
|
||||||
streams = [m.groupdict() for m in re.finditer(self._MEDIA_STREAM, html)]
|
streams = [m.groupdict() for m in re.finditer(self._MEDIA_STREAM, html)]
|
||||||
if streams is None:
|
if streams is None:
|
||||||
@ -27,39 +28,48 @@ class ZDFIE(InfoExtractor):
|
|||||||
# s['media_type'] == 'wstreaming' -> use 'Windows Media Player' and mms url
|
# s['media_type'] == 'wstreaming' -> use 'Windows Media Player' and mms url
|
||||||
# s['media_type'] == 'hstreaming' -> use 'Quicktime' and rtsp url
|
# s['media_type'] == 'hstreaming' -> use 'Quicktime' and rtsp url
|
||||||
# choose first/default media type and highest quality for now
|
# choose first/default media type and highest quality for now
|
||||||
for s in streams: #find 300 - dsl1000mbit
|
def stream_pref(s):
|
||||||
if s['quality'] == '300' and s['media_type'] == 'wstreaming':
|
TYPE_ORDER = ['ostreaming', 'hstreaming', 'wstreaming']
|
||||||
stream_=s
|
try:
|
||||||
break
|
type_pref = TYPE_ORDER.index(s['media_type'])
|
||||||
for s in streams: #find veryhigh - dsl2000mbit
|
except ValueError:
|
||||||
if s['quality'] == 'veryhigh' and s['media_type'] == 'wstreaming': # 'hstreaming' - rtsp is not working
|
type_pref = 999
|
||||||
stream_=s
|
|
||||||
break
|
QUALITY_ORDER = ['veryhigh', '300']
|
||||||
if stream_ is None:
|
try:
|
||||||
|
quality_pref = QUALITY_ORDER.index(s['quality'])
|
||||||
|
except ValueError:
|
||||||
|
quality_pref = 999
|
||||||
|
|
||||||
|
return (type_pref, quality_pref)
|
||||||
|
|
||||||
|
sorted_streams = sorted(streams, key=stream_pref)
|
||||||
|
if not sorted_streams:
|
||||||
raise ExtractorError(u'No stream found.')
|
raise ExtractorError(u'No stream found.')
|
||||||
|
stream = sorted_streams[0]
|
||||||
|
|
||||||
media_link = self._download_webpage(stream_['video_url'], video_id,'Get stream URL')
|
media_link = self._download_webpage(
|
||||||
|
stream['video_url'],
|
||||||
|
video_id,
|
||||||
|
u'Get stream URL')
|
||||||
|
|
||||||
self.report_extraction(video_id)
|
MMS_STREAM = r'href="(?P<video_url>mms://[^"]*)"'
|
||||||
mobj = re.search(self._TITLE, html)
|
RTSP_STREAM = r'(?P<video_url>rtsp://[^"]*.mp4)'
|
||||||
|
|
||||||
|
mobj = re.search(self._MEDIA_STREAM, media_link)
|
||||||
if mobj is None:
|
if mobj is None:
|
||||||
raise ExtractorError(u'Cannot extract title')
|
mobj = re.search(RTSP_STREAM, media_link)
|
||||||
title = unescapeHTML(mobj.group('title'))
|
|
||||||
|
|
||||||
mobj = re.search(self._MMS_STREAM, media_link)
|
|
||||||
if mobj is None:
|
|
||||||
mobj = re.search(self._RTSP_STREAM, media_link)
|
|
||||||
if mobj is None:
|
if mobj is None:
|
||||||
raise ExtractorError(u'Cannot extract mms:// or rtsp:// URL')
|
raise ExtractorError(u'Cannot extract mms:// or rtsp:// URL')
|
||||||
mms_url = mobj.group('video_url')
|
video_url = mobj.group('video_url')
|
||||||
|
|
||||||
mobj = re.search('(.*)[.](?P<ext>[^.]+)', mms_url)
|
title = self._html_search_regex(
|
||||||
if mobj is None:
|
r'<h1(?: class="beitragHeadline")?>(.*?)</h1>',
|
||||||
raise ExtractorError(u'Cannot extract extention')
|
html, u'title')
|
||||||
ext = mobj.group('ext')
|
|
||||||
|
|
||||||
return [{'id': video_id,
|
return {
|
||||||
'url': mms_url,
|
'id': video_id,
|
||||||
'title': title,
|
'url': video_url,
|
||||||
'ext': ext
|
'title': title,
|
||||||
}]
|
'ext': determine_ext(video_url)
|
||||||
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import io
|
||||||
import json
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
from zipimport import zipimporter
|
from zipimport import zipimporter
|
||||||
|
|
||||||
from .utils import *
|
from .utils import *
|
||||||
@ -34,7 +37,7 @@ def rsa_verify(message, signature, key):
|
|||||||
if signature != sha256(message).digest(): return False
|
if signature != sha256(message).digest(): return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def update_self(to_screen, verbose, filename):
|
def update_self(to_screen, verbose):
|
||||||
"""Update the program file with the latest version from the repository"""
|
"""Update the program file with the latest version from the repository"""
|
||||||
|
|
||||||
UPDATE_URL = "http://rg3.github.io/youtube-dl/update/"
|
UPDATE_URL = "http://rg3.github.io/youtube-dl/update/"
|
||||||
@ -42,7 +45,6 @@ def update_self(to_screen, verbose, filename):
|
|||||||
JSON_URL = UPDATE_URL + 'versions.json'
|
JSON_URL = UPDATE_URL + 'versions.json'
|
||||||
UPDATES_RSA_KEY = (0x9d60ee4d8f805312fdb15a62f87b95bd66177b91df176765d13514a0f1754bcd2057295c5b6f1d35daa6742c3ffc9a82d3e118861c207995a8031e151d863c9927e304576bc80692bc8e094896fcf11b66f3e29e04e3a71e9a11558558acea1840aec37fc396fb6b65dc81a1c4144e03bd1c011de62e3f1357b327d08426fe93, 65537)
|
UPDATES_RSA_KEY = (0x9d60ee4d8f805312fdb15a62f87b95bd66177b91df176765d13514a0f1754bcd2057295c5b6f1d35daa6742c3ffc9a82d3e118861c207995a8031e151d863c9927e304576bc80692bc8e094896fcf11b66f3e29e04e3a71e9a11558558acea1840aec37fc396fb6b65dc81a1c4144e03bd1c011de62e3f1357b327d08426fe93, 65537)
|
||||||
|
|
||||||
|
|
||||||
if not isinstance(globals().get('__loader__'), zipimporter) and not hasattr(sys, "frozen"):
|
if not isinstance(globals().get('__loader__'), zipimporter) and not hasattr(sys, "frozen"):
|
||||||
to_screen(u'It looks like you installed youtube-dl with a package manager, pip, setup.py or a tarball. Please use that to update.')
|
to_screen(u'It looks like you installed youtube-dl with a package manager, pip, setup.py or a tarball. Please use that to update.')
|
||||||
return
|
return
|
||||||
@ -75,11 +77,18 @@ def update_self(to_screen, verbose, filename):
|
|||||||
to_screen(u'ERROR: the versions file signature is invalid. Aborting.')
|
to_screen(u'ERROR: the versions file signature is invalid. Aborting.')
|
||||||
return
|
return
|
||||||
|
|
||||||
to_screen(u'Updating to version ' + versions_info['latest'] + '...')
|
version_id = versions_info['latest']
|
||||||
version = versions_info['versions'][versions_info['latest']]
|
to_screen(u'Updating to version ' + version_id + '...')
|
||||||
|
version = versions_info['versions'][version_id]
|
||||||
|
|
||||||
print_notes(to_screen, versions_info['versions'])
|
print_notes(to_screen, versions_info['versions'])
|
||||||
|
|
||||||
|
filename = sys.argv[0]
|
||||||
|
# Py2EXE: Filename could be different
|
||||||
|
if hasattr(sys, "frozen") and not os.path.isfile(filename):
|
||||||
|
if os.path.isfile(filename + u'.exe'):
|
||||||
|
filename += u'.exe'
|
||||||
|
|
||||||
if not os.access(filename, os.W_OK):
|
if not os.access(filename, os.W_OK):
|
||||||
to_screen(u'ERROR: no write permissions on %s' % filename)
|
to_screen(u'ERROR: no write permissions on %s' % filename)
|
||||||
return
|
return
|
||||||
@ -116,16 +125,18 @@ def update_self(to_screen, verbose, filename):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
bat = os.path.join(directory, 'youtube-dl-updater.bat')
|
bat = os.path.join(directory, 'youtube-dl-updater.bat')
|
||||||
b = open(bat, 'w')
|
with io.open(bat, 'w') as batfile:
|
||||||
b.write("""
|
batfile.write(u"""
|
||||||
echo Updating youtube-dl...
|
@echo off
|
||||||
|
echo Waiting for file handle to be closed ...
|
||||||
ping 127.0.0.1 -n 5 -w 1000 > NUL
|
ping 127.0.0.1 -n 5 -w 1000 > NUL
|
||||||
move /Y "%s.new" "%s"
|
move /Y "%s.new" "%s" > NUL
|
||||||
del "%s"
|
echo Updated youtube-dl to version %s.
|
||||||
\n""" %(exe, exe, bat))
|
start /b "" cmd /c del "%%~f0"&exit /b"
|
||||||
b.close()
|
\n""" % (exe, exe, version_id))
|
||||||
|
|
||||||
os.startfile(bat)
|
subprocess.Popen([bat]) # Continues to run in the background
|
||||||
|
return # Do not show premature success messages
|
||||||
except (IOError, OSError) as err:
|
except (IOError, OSError) as err:
|
||||||
if verbose: to_screen(compat_str(traceback.format_exc()))
|
if verbose: to_screen(compat_str(traceback.format_exc()))
|
||||||
to_screen(u'ERROR: unable to overwrite current version')
|
to_screen(u'ERROR: unable to overwrite current version')
|
||||||
|
@ -175,7 +175,7 @@ def compat_ord(c):
|
|||||||
compiled_regex_type = type(re.compile(''))
|
compiled_regex_type = type(re.compile(''))
|
||||||
|
|
||||||
std_headers = {
|
std_headers = {
|
||||||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0',
|
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 (Chrome)',
|
||||||
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
|
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
|
||||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||||
'Accept-Encoding': 'gzip, deflate',
|
'Accept-Encoding': 'gzip, deflate',
|
||||||
@ -824,3 +824,9 @@ def intlist_to_bytes(xs):
|
|||||||
return ''.join([chr(x) for x in xs])
|
return ''.join([chr(x) for x in xs])
|
||||||
else:
|
else:
|
||||||
return bytes(xs)
|
return bytes(xs)
|
||||||
|
|
||||||
|
|
||||||
|
def get_cachedir(params={}):
|
||||||
|
cache_root = os.environ.get('XDG_CACHE_HOME',
|
||||||
|
os.path.expanduser('~/.cache'))
|
||||||
|
return params.get('cachedir', os.path.join(cache_root, 'youtube-dl'))
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
|
|
||||||
__version__ = '2013.09.24.2'
|
__version__ = '2013.10.06'
|
||||||
|
Reference in New Issue
Block a user