|
|
@ -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
|
|
|
|
|
|
|
|
|
|
|
|