mirror of
https://github.com/soimort/you-get.git
synced 2025-02-10 20:22:27 +03:00
commit
f7fb645b07
@ -235,7 +235,7 @@ def url_save(url, filepath, bar, refer = None, is_part = False, faker = False):
|
|||||||
if bar:
|
if bar:
|
||||||
bar.update_received(len(buffer))
|
bar.update_received(len(buffer))
|
||||||
|
|
||||||
assert received == os.path.getsize(temp_filepath), '%s == %s == %s' % (received, os.path.getsize(temp_filepath))
|
assert received == os.path.getsize(temp_filepath), '%s == %s == %s' % (received, os.path.getsize(temp_filepath), temp_filepath)
|
||||||
|
|
||||||
if os.access(filepath, os.W_OK):
|
if os.access(filepath, os.W_OK):
|
||||||
os.remove(filepath) # on Windows rename could fail if destination filepath exists
|
os.remove(filepath) # on Windows rename could fail if destination filepath exists
|
||||||
@ -444,8 +444,8 @@ def download_urls(urls, title, ext, total_size, output_dir = '.', refer = None,
|
|||||||
except:
|
except:
|
||||||
from .processor.ffmpeg import has_ffmpeg_installed
|
from .processor.ffmpeg import has_ffmpeg_installed
|
||||||
if has_ffmpeg_installed():
|
if has_ffmpeg_installed():
|
||||||
from .processor.ffmpeg import ffmpeg_concat_mp4_to_mpg
|
from .processor.ffmpeg import ffmpeg_concat_mp4_to_mp4
|
||||||
ffmpeg_concat_mp4_to_mpg(parts, os.path.join(output_dir, title + '.mp4'))
|
ffmpeg_concat_mp4_to_mp4(parts, os.path.join(output_dir, title + '.mp4'))
|
||||||
for part in parts:
|
for part in parts:
|
||||||
os.remove(part)
|
os.remove(part)
|
||||||
else:
|
else:
|
||||||
|
@ -7,9 +7,9 @@ from ..common import *
|
|||||||
def mixcloud_download(url, output_dir = '.', merge = True, info_only = False):
|
def mixcloud_download(url, output_dir = '.', merge = True, info_only = False):
|
||||||
html = get_html(url)
|
html = get_html(url)
|
||||||
title = r1(r'<meta property="og:title" content="([^"]*)"', html)
|
title = r1(r'<meta property="og:title" content="([^"]*)"', html)
|
||||||
url = r1("data-preview-url=\"([^\"]+)\"", html)
|
preview_url = r1("data-preview-url=\"([^\"]+)\"", html)
|
||||||
|
|
||||||
url = re.sub(r'previews', r'cloudcasts/originals', url)
|
url = re.sub(r'previews', r'cloudcasts/originals', preview_url)
|
||||||
for i in range(10, 30):
|
for i in range(10, 30):
|
||||||
url = re.sub(r'stream[^.]*', r'stream' + str(i), url)
|
url = re.sub(r'stream[^.]*', r'stream' + str(i), url)
|
||||||
|
|
||||||
@ -19,6 +19,20 @@ def mixcloud_download(url, output_dir = '.', merge = True, info_only = False):
|
|||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
type
|
||||||
|
except:
|
||||||
|
url = re.sub('cloudcasts/originals', r'cloudcasts/m4a/64', url)
|
||||||
|
url = re.sub('.mp3', '.m4a', url)
|
||||||
|
for i in range(10, 30):
|
||||||
|
url = re.sub(r'stream[^.]*', r'stream' + str(i), url)
|
||||||
|
|
||||||
|
try:
|
||||||
|
type, ext, size = url_info(url)
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
print_info(site_info, title, type, size)
|
print_info(site_info, title, type, size)
|
||||||
if not info_only:
|
if not info_only:
|
||||||
download_urls([url], title, ext, size, output_dir, merge = merge)
|
download_urls([url], title, ext, size, output_dir, merge = merge)
|
||||||
|
@ -22,12 +22,17 @@ def tudou_download_by_iid(iid, title, output_dir = '.', merge = True, info_only
|
|||||||
#url_save(url, filepath, bar):
|
#url_save(url, filepath, bar):
|
||||||
download_urls([url], title, ext, total_size = None, output_dir = output_dir, merge = merge)
|
download_urls([url], title, ext, total_size = None, output_dir = output_dir, merge = merge)
|
||||||
|
|
||||||
def tudou_download_by_id(id, title, output_dir = '.', merge = True):
|
def tudou_download_by_id(id, title, output_dir = '.', merge = True, info_only = False):
|
||||||
html = get_html('http://www.tudou.com/programs/view/%s/' % id)
|
html = get_html('http://www.tudou.com/programs/view/%s/' % id)
|
||||||
iid = r1(r'iid\s*=\s*(\S+)', html)
|
iid = r1(r'iid\s*[:=]\s*(\S+)', html)
|
||||||
tudou_download_by_iid(iid, title, output_dir = output_dir, merge = merge)
|
tudou_download_by_iid(iid, title, output_dir = output_dir, merge = merge, info_only = info_only)
|
||||||
|
|
||||||
def tudou_download(url, output_dir = '.', merge = True, info_only = False):
|
def tudou_download(url, output_dir = '.', merge = True, info_only = False):
|
||||||
|
# Embedded player
|
||||||
|
id = r1(r'http://www.tudou.com/v/([^/]+)/', url)
|
||||||
|
if id:
|
||||||
|
return tudou_download_by_id(id, title="", info_only=info_only)
|
||||||
|
|
||||||
html = get_decoded_html(url)
|
html = get_decoded_html(url)
|
||||||
|
|
||||||
title = r1(r'kw\s*[:=]\s*[\'\"]([^\']+?)[\'\"]', html)
|
title = r1(r'kw\s*[:=]\s*[\'\"]([^\']+?)[\'\"]', html)
|
||||||
|
@ -96,3 +96,31 @@ def ffmpeg_concat_flv_to_mp4(files, output = 'output.mp4'):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def ffmpeg_concat_mp4_to_mp4(files, output = 'output.mp4'):
|
||||||
|
for file in files:
|
||||||
|
if os.path.isfile(file):
|
||||||
|
params = [FFMPEG, '-i']
|
||||||
|
params.append(file)
|
||||||
|
params += ['-c', 'copy', '-f', 'mpegts', '-bsf:v', 'h264_mp4toannexb']
|
||||||
|
params.append(file + '.ts')
|
||||||
|
|
||||||
|
subprocess.call(params)
|
||||||
|
|
||||||
|
params = [FFMPEG, '-i']
|
||||||
|
params.append('concat:')
|
||||||
|
for file in files:
|
||||||
|
f = file + '.ts'
|
||||||
|
if os.path.isfile(f):
|
||||||
|
params[-1] += f + '|'
|
||||||
|
if FFMPEG == 'avconv':
|
||||||
|
params += ['-c', 'copy', output]
|
||||||
|
else:
|
||||||
|
params += ['-c', 'copy', '-absf', 'aac_adtstoasc', output]
|
||||||
|
|
||||||
|
if subprocess.call(params) == 0:
|
||||||
|
for file in files:
|
||||||
|
os.remove(file + '.ts')
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
@ -19,7 +19,7 @@ class YouGetTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_jpopsuki(self):
|
def test_jpopsuki(self):
|
||||||
test_urls([
|
test_urls([
|
||||||
"http://jpopsuki.tv/video/Dragon-Ash---Run-to-the-Sun/8ad7aec604badd0b0798cd999b63ae17",
|
#"http://jpopsuki.tv/video/Dragon-Ash---Run-to-the-Sun/8ad7aec604badd0b0798cd999b63ae17",
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_mixcloud(self):
|
def test_mixcloud(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user