diff --git a/setup.py b/setup.py
index 24dc9fb2..3b65a18c 100755
--- a/setup.py
+++ b/setup.py
@@ -1,21 +1,27 @@
#!/usr/bin/env python3
+import importlib
+import json
+import os
+
+from setuptools import find_packages, setup
+
+
PROJ_NAME = 'you-get'
PACKAGE_NAME = 'you_get'
PROJ_METADATA = '%s.json' % PROJ_NAME
-import os, json, imp
here = os.path.abspath(os.path.dirname(__file__))
proj_info = json.loads(open(os.path.join(here, PROJ_METADATA), encoding='utf-8').read())
try:
README = open(os.path.join(here, 'README.rst'), encoding='utf-8').read()
-except:
+except Exception:
README = ""
CHANGELOG = open(os.path.join(here, 'CHANGELOG.rst'), encoding='utf-8').read()
-VERSION = imp.load_source('version', os.path.join(here, 'src/%s/version.py' % PACKAGE_NAME)).__version__
+VERSION = importlib.load_source('version', os.path.join(here, 'src/%s/version.py' % PACKAGE_NAME)).__version__
+
-from setuptools import setup, find_packages
setup(
name = proj_info['name'],
version = VERSION,
diff --git a/src/you_get/__main__.py b/src/you_get/__main__.py
index b7ec6f04..3617bbb8 100644
--- a/src/you_get/__main__.py
+++ b/src/you_get/__main__.py
@@ -4,8 +4,9 @@ import getopt
import os
import platform
import sys
-from .version import script_name, __version__
+
from .util import git, log
+from .version import __version__, script_name
_options = [
'help',
@@ -60,7 +61,7 @@ def main_dev(**kwargs):
log.println(" branch: {}\n commit: {}".format("(stable)", "(tag v{})".format(__version__)))
log.println(" platform: {}".format(platform.platform()))
- log.println(" python: {}".format(sys.version.split('\n')[0]))
+ log.println(" python: {}".format(sys.version.split('\n', maxsplit=1)[0]))
elif opt in ('-g', '--gui'):
# Run using GUI.
diff --git a/src/you_get/common.py b/src/you_get/common.py
index c5c19d01..188b3da2 100755
--- a/src/you_get/common.py
+++ b/src/you_get/common.py
@@ -1,25 +1,26 @@
#!/usr/bin/env python
+import argparse
import io
-import os
-import re
-import sys
-import time
import json
-import socket
import locale
import logging
-import argparse
+import os
+import re
+import socket
import ssl
+import sys
+import time
from http import cookiejar
from importlib import import_module
-from urllib import request, parse, error
+from urllib import error, parse, request
-from .version import __version__
+from . import json_output as json_output_
from .util import log, term
from .util.git import get_version
from .util.strings import get_filename, unescape_html
-from . import json_output as json_output_
+from .version import __version__
+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
SITES = {
@@ -195,7 +196,7 @@ def general_m3u8_extractor(url, headers={}):
def maybe_print(*s):
try:
print(*s)
- except:
+ except Exception:
pass
@@ -270,15 +271,15 @@ def matchall(text, patterns):
def launch_player(player, urls):
- import subprocess
import shlex
+ import subprocess
urls = list(urls)
for url in urls.copy():
if type(url) is list:
urls.extend(url)
urls = [url for url in urls if type(url) is str]
assert urls
- if (sys.version_info >= (3, 3)):
+ if sys.version_info >= (3, 3):
import shutil
exefile=shlex.split(player)[0]
if shutil.which(exefile) is not None:
@@ -302,7 +303,7 @@ def parse_query_param(url, param):
try:
return parse.parse_qs(parse.urlparse(url).query)[param][0]
- except:
+ except Exception:
return None
@@ -326,8 +327,8 @@ def escape_file_path(path):
def ungzip(data):
"""Decompresses data for Content-Encoding: gzip.
"""
- from io import BytesIO
import gzip
+ from io import BytesIO
buffer = BytesIO(data)
f = gzip.GzipFile(fileobj=buffer)
return f.read()
@@ -629,7 +630,7 @@ def url_info(url, faker=False, headers={}):
ext = filename.split('.')[-1]
else:
ext = None
- except:
+ except Exception:
ext = None
else:
ext = None
@@ -711,7 +712,7 @@ def url_save(
if not force and auto_rename:
path, ext = os.path.basename(filepath).rsplit('.', 1)
finder = re.compile(' \([1-9]\d*?\)$')
- if (finder.search(path) is None):
+ if finder.search(path) is None:
thisfile = path + ' (1).' + ext
else:
def numreturn(a):
@@ -781,7 +782,7 @@ def url_save(
response.headers['content-range'][6:].split('/')[1]
)
range_length = end_length - range_start
- except:
+ except Exception:
content_length = response.headers['content-length']
range_length = int(content_length) if content_length is not None \
else float('inf')
@@ -855,8 +856,7 @@ class SimpleProgressBar:
self.displayed = True
bar_size = self.bar_size
percent = round(self.received * 100 / self.total_size, 1)
- if percent >= 100:
- percent = 100
+ percent = min(percent, 100)
dots = bar_size * int(percent) // 100
plus = int(percent) - dots // bar_size * 100
if plus > 0.8:
@@ -992,7 +992,7 @@ def download_urls(
print_user_agent(faker=faker)
try:
print('Real URLs:\n%s' % '\n'.join(urls))
- except:
+ except Exception:
print('Real URLs:\n%s' % '\n'.join([j for i in urls for j in i]))
return
@@ -1003,7 +1003,7 @@ def download_urls(
if not total_size:
try:
total_size = urls_size(urls, faker=faker, headers=headers)
- except:
+ except Exception:
import traceback
traceback.print_exc(file=sys.stdout)
pass
@@ -1077,7 +1077,7 @@ def download_urls(
from .processor.join_flv import concat_flv
concat_flv(parts, output_filepath)
print('Merged into %s' % output_filename)
- except:
+ except Exception:
raise
else:
for part in parts:
@@ -1093,7 +1093,7 @@ def download_urls(
from .processor.join_mp4 import concat_mp4
concat_mp4(parts, output_filepath)
print('Merged into %s' % output_filename)
- except:
+ except Exception:
raise
else:
for part in parts:
@@ -1109,7 +1109,7 @@ def download_urls(
from .processor.join_ts import concat_ts
concat_ts(parts, output_filepath)
print('Merged into %s' % output_filename)
- except:
+ except Exception:
raise
else:
for part in parts:
@@ -1123,7 +1123,7 @@ def download_urls(
from .processor.ffmpeg import ffmpeg_concat_mp3_to_mp3
ffmpeg_concat_mp3_to_mp3(parts, output_filepath)
print('Merged into %s' % output_filename)
- except:
+ except Exception:
raise
else:
for part in parts:
@@ -1152,9 +1152,8 @@ def download_rtmp_url(
play_rtmpdump_stream(player, url, params)
return
- from .processor.rtmpdump import (
- has_rtmpdump_installed, download_rtmpdump_stream
- )
+ from .processor.rtmpdump import (download_rtmpdump_stream,
+ has_rtmpdump_installed)
assert has_rtmpdump_installed(), 'RTMPDump not installed.'
download_rtmpdump_stream(url, title, ext, params, output_dir)
@@ -1175,7 +1174,7 @@ def download_url_ffmpeg(
launch_player(player, [url])
return
- from .processor.ffmpeg import has_ffmpeg_installed, ffmpeg_download_stream
+ from .processor.ffmpeg import ffmpeg_download_stream, has_ffmpeg_installed
assert has_ffmpeg_installed(), 'FFmpeg not installed.'
global output_filename
@@ -1397,7 +1396,8 @@ def load_cookies(cookiefile):
with open(cookiefile, 'r', encoding='utf-8') as f:
for line in f:
# last field may be absent, so keep any trailing tab
- if line.endswith("\n"): line = line[:-1]
+ if line.endswith("\n"):
+ line = line[:-1]
# skip comments and blank lines XXX what is $ for?
if (line.strip().startswith(("#", "$")) or
@@ -1443,7 +1443,9 @@ def load_cookies(cookiefile):
cookies.set_cookie(c)
elif cookiefile.endswith(('.sqlite', '.sqlite3')):
- import sqlite3, shutil, tempfile
+ import shutil
+ import sqlite3
+ import tempfile
temp_dir = tempfile.gettempdir()
temp_cookiefile = os.path.join(temp_dir, 'temp_cookiefile.sqlite')
shutil.copy2(cookiefile, temp_cookiefile)
@@ -1486,12 +1488,12 @@ def set_socks_proxy(proxy):
socks_proxy_auth[1]
)
else:
- socks_proxy_addrs = proxy.split(':')
- socks.set_default_proxy(
- socks.SOCKS5,
- socks_proxy_addrs[0],
- int(socks_proxy_addrs[1]),
- )
+ socks_proxy_addrs = proxy.split(':')
+ socks.set_default_proxy(
+ socks.SOCKS5,
+ socks_proxy_addrs[0],
+ int(socks_proxy_addrs[1]),
+ )
socket.socket = socks.socksocket
def getaddrinfo(*args):
@@ -1812,7 +1814,7 @@ def google_search(url):
r'(https://www\.youtube\.com/watch\?v=[\w-]+)', page
)
print('Best matched result:')
- return(videos[0])
+ return videos[0]
def url_to_module(url):
@@ -1844,7 +1846,7 @@ def url_to_module(url):
else:
try:
location = get_location(url) # t.co isn't happy with fake_headers
- except:
+ except Exception:
location = get_location(url, headers=fake_headers)
if location and location != url and not location.startswith('/'):
diff --git a/src/you_get/extractor.py b/src/you_get/extractor.py
index bd71717e..b7afefda 100644
--- a/src/you_get/extractor.py
+++ b/src/you_get/extractor.py
@@ -1,12 +1,16 @@
#!/usr/bin/env python
-from .common import match1, maybe_print, download_urls, get_filename, parse_host, set_proxy, unset_proxy, get_content, dry_run, player
-from .common import print_more_compatible as print
-from .util import log
-from . import json_output
import os
import sys
+from . import json_output
+from .common import (download_urls, dry_run, get_content, get_filename, match1,
+ maybe_print, parse_host, player)
+from .common import print_more_compatible as print
+from .common import set_proxy, unset_proxy
+from .util import log
+
+
class Extractor():
def __init__(self, *args):
self.url = None
@@ -53,7 +57,7 @@ class VideoExtractor():
try:
self.streams_sorted = [dict([('id', stream_type['id'])] + list(self.streams[stream_type['id']].items())) for stream_type in self.__class__.stream_types if stream_type['id'] in self.streams]
- except:
+ except Exception:
self.streams_sorted = [dict([('itag', stream_type['itag'])] + list(self.streams[stream_type['itag']].items())) for stream_type in self.__class__.stream_types if stream_type['itag'] in self.streams]
self.extract(**kwargs)
@@ -72,7 +76,7 @@ class VideoExtractor():
try:
self.streams_sorted = [dict([('id', stream_type['id'])] + list(self.streams[stream_type['id']].items())) for stream_type in self.__class__.stream_types if stream_type['id'] in self.streams]
- except:
+ except Exception:
self.streams_sorted = [dict([('itag', stream_type['itag'])] + list(self.streams[stream_type['itag']].items())) for stream_type in self.__class__.stream_types if stream_type['itag'] in self.streams]
self.extract(**kwargs)
diff --git a/src/you_get/extractors/__init__.py b/src/you_get/extractors/__init__.py
index 8c43a8bc..e1967a53 100755
--- a/src/you_get/extractors/__init__.py
+++ b/src/you_get/extractors/__init__.py
@@ -33,9 +33,9 @@ from .interest import *
from .iqilu import *
from .iqiyi import *
from .joy import *
+from .kakao import *
from .khan import *
from .ku6 import *
-from .kakao import *
from .kuaishou import *
from .kugou import *
from .kuwo import *
diff --git a/src/you_get/extractors/acfun.py b/src/you_get/extractors/acfun.py
index cd275927..fdb3d704 100644
--- a/src/you_get/extractors/acfun.py
+++ b/src/you_get/extractors/acfun.py
@@ -3,6 +3,7 @@
from ..common import *
from ..extractor import VideoExtractor
+
class AcFun(VideoExtractor):
name = "AcFun"
@@ -15,7 +16,7 @@ class AcFun(VideoExtractor):
{'id': '720P', 'qualityType': '720p'},
{'id': '540P', 'qualityType': '540p'},
{'id': '360P', 'qualityType': '360p'}
- ]
+ ]
def prepare(self, **kwargs):
assert re.match(r'https?://[^\.]*\.*acfun\.[^\.]+/(\D|bangumi)/\D\D(\d+)', self.url)
@@ -43,7 +44,7 @@ class AcFun(VideoExtractor):
currentVideoInfo = json_data.get('currentVideoInfo')
else:
- raise NotImplemented
+ raise NotImplemented
if 'ksPlayJson' in currentVideoInfo:
durationMillis = currentVideoInfo['durationMillis']
@@ -58,7 +59,7 @@ class AcFun(VideoExtractor):
container = 'mp4'
stream_id = stream["qualityLabel"]
quality = stream["qualityType"]
-
+
stream_data = dict(src=m3u8_url, size=size, container=container, quality=quality)
self.streams[stream_id] = stream_data
@@ -68,7 +69,7 @@ class AcFun(VideoExtractor):
p_title = r1('active">([^<]+)', html)
self.title = '%s (%s)' % (self.title, up)
if p_title:
- self.title = '%s - %s' % (self.title, p_title)
+ self.title = '%s - %s' % (self.title, p_title)
def download(self, **kwargs):
@@ -119,7 +120,7 @@ class AcFun(VideoExtractor):
if self.referer is not None:
headers['Referer'] = self.referer
- download_url_ffmpeg(url, self.title, ext, output_dir=kwargs['output_dir'], merge=kwargs['merge'])
+ download_url_ffmpeg(url, self.title, ext, output_dir=kwargs['output_dir'], merge=kwargs['merge'])
if 'caption' not in kwargs or not kwargs['caption']:
print('Skipping captions or danmaku.')
diff --git a/src/you_get/extractors/alive.py b/src/you_get/extractors/alive.py
index 5d6e2b2a..d39248b3 100644
--- a/src/you_get/extractors/alive.py
+++ b/src/you_get/extractors/alive.py
@@ -4,14 +4,15 @@ __all__ = ['alive_download']
from ..common import *
+
def alive_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
html = get_html(url)
-
+
title = r1(r'list
-
+
Get the height of the videos.
-
+
Since brightcove is using 3 kinds of links: rtmp, http and https,
we will be using the HTTPS one to make it secure.
-
+
If somehow akamaihd.net is blocked by the Great Fucking Wall,
change the "startswith https" to http.
"""
@@ -57,7 +58,7 @@ class Bigthink(VideoExtractor):
account_number = match1(html, r'data-account="(\d+)"')
video_id = match1(html, r'data-brightcove-id="(\d+)"')
-
+
assert account_number, video_id
link_list = self.get_streams_by_id(account_number, video_id)
diff --git a/src/you_get/extractors/bilibili.py b/src/you_get/extractors/bilibili.py
index 6d34c2c4..54b1f52b 100644
--- a/src/you_get/extractors/bilibili.py
+++ b/src/you_get/extractors/bilibili.py
@@ -1,11 +1,13 @@
#!/usr/bin/env python
-from ..common import *
-from ..extractor import VideoExtractor
+import sys
import hashlib
import math
+from ..common import *
+from ..extractor import VideoExtractor
+
class Bilibili(VideoExtractor):
name = "Bilibili"
@@ -115,7 +117,7 @@ class Bilibili(VideoExtractor):
@staticmethod
def bilibili_space_channel_api(mid, cid, pn=1, ps=100):
return 'https://api.bilibili.com/x/space/channel/video?mid=%s&cid=%s&pn=%s&ps=%s&order=0&jsonp=jsonp' % (mid, cid, pn, ps)
-
+
@staticmethod
def bilibili_space_collection_api(mid, cid, pn=1, ps=30):
return 'https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid=%s&season_id=%s&sort_reverse=false&page_num=%s&page_size=%s' % (mid, cid, pn, ps)
@@ -123,7 +125,7 @@ class Bilibili(VideoExtractor):
@staticmethod
def bilibili_series_archives_api(mid, sid, pn=1, ps=100):
return 'https://api.bilibili.com/x/series/archives?mid=%s&series_id=%s&pn=%s&ps=%s&only_normal=true&sort=asc&jsonp=jsonp' % (mid, sid, pn, ps)
-
+
@staticmethod
def bilibili_space_favlist_api(fid, pn=1, ps=20):
return 'https://api.bilibili.com/x/v3/fav/resource/list?media_id=%s&pn=%s&ps=%s&order=mtime&type=0&tid=0&jsonp=jsonp' % (fid, pn, ps)
@@ -144,7 +146,7 @@ class Bilibili(VideoExtractor):
def url_size(url, faker=False, headers={},err_value=0):
try:
return url_size(url,faker,headers)
- except:
+ except Exception:
return err_value
def prepare(self, **kwargs):
@@ -154,7 +156,7 @@ class Bilibili(VideoExtractor):
try:
html_content = get_content(self.url, headers=self.bilibili_headers(referer=self.url))
- except:
+ except Exception:
html_content = '' # live always returns 400 (why?)
#self.title = match1(html_content,
# r'
None
-
+
Keyword arguments:
self: self
vid: The video ID for BokeCC cloud, something like
FE3BB999594978049C33DC5901307461
-
+
Calls the prepare() to download the video.
-
+
If no title is provided, this method shall try to find a proper title
with the information providin within the
returned content of the API."""
@@ -34,8 +36,8 @@ class BokeCC(VideoExtractor):
self.extract(**kwargs)
- self.download(output_dir = output_dir,
- merge = merge,
+ self.download(output_dir = output_dir,
+ merge = merge,
info_only = info_only, **kwargs)
def prepare(self, vid = '', title = None, **kwargs):
@@ -49,7 +51,7 @@ class BokeCC(VideoExtractor):
if self.tree.find('result').text != '1':
log.wtf('API result says failed!')
- raise
+ raise
if title is None:
self.title = '_'.join([i.text for i in self.tree.iterfind('video/videomarks/videomark/markdesc')])
@@ -81,7 +83,7 @@ class BokeCC(VideoExtractor):
if stream_id not in self.streams:
log.e('[Error] Invalid video format.')
log.e('Run \'-i\' command with no specific video format to view all available formats.')
- exit(2)
+ sys.exit(2)
else:
# Extract stream with the best quality
stream_id = self.streams_sorted[0]['id']
diff --git a/src/you_get/extractors/cbs.py b/src/you_get/extractors/cbs.py
index 342eb249..d8658db5 100644
--- a/src/you_get/extractors/cbs.py
+++ b/src/you_get/extractors/cbs.py
@@ -3,9 +3,9 @@
__all__ = ['cbs_download']
from ..common import *
-
from .theplatform import theplatform_download_by_pid
+
def cbs_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
"""Downloads CBS videos by URL.
"""
diff --git a/src/you_get/extractors/ckplayer.py b/src/you_get/extractors/ckplayer.py
index 5ff1f7b1..81b3bef9 100644
--- a/src/you_get/extractors/ckplayer.py
+++ b/src/you_get/extractors/ckplayer.py
@@ -6,9 +6,12 @@
__all__ = ['ckplayer_download']
-from xml.etree import ElementTree as ET
from copy import copy
+from xml.etree import ElementTree as ET
+
from ..common import *
+
+
#----------------------------------------------------------------------
def ckplayer_get_info_by_xml(ckinfo):
"""str->dict
@@ -57,23 +60,23 @@ def dictify(r,root=True):
def ckplayer_download_by_xml(ckinfo, output_dir = '.', merge = False, info_only = False, **kwargs):
#Info XML
video_info = ckplayer_get_info_by_xml(ckinfo)
-
+
try:
title = kwargs['title']
- except:
+ except Exception:
title = ''
type_ = ''
size = 0
-
+
if len(video_info['links']) > 0: #has link
type_, _ext, size = url_info(video_info['links'][0]) #use 1st to determine type, ext
-
+
if 'size' in video_info:
size = int(video_info['size'])
else:
for i in video_info['links'][1:]: #save 1st one
size += url_info(i)[2]
-
+
print_info(site_info, title, type_, size)
if not info_only:
download_urls(video_info['links'], title, _ext, size, output_dir=output_dir, merge=merge)
@@ -83,15 +86,15 @@ def ckplayer_download(url, output_dir = '.', merge = False, info_only = False, i
if is_xml: #URL is XML URL
try:
title = kwargs['title']
- except:
+ except Exception:
title = ''
try:
headers = kwargs['headers'] #headers provided
ckinfo = get_content(url, headers = headers)
except NameError:
ckinfo = get_content(url)
-
- ckplayer_download_by_xml(ckinfo, output_dir, merge,
+
+ ckplayer_download_by_xml(ckinfo, output_dir, merge,
info_only, title = title)
site_info = "CKPlayer General"
diff --git a/src/you_get/extractors/cntv.py b/src/you_get/extractors/cntv.py
index a56cde6f..9744fab9 100644
--- a/src/you_get/extractors/cntv.py
+++ b/src/you_get/extractors/cntv.py
@@ -3,7 +3,7 @@
import json
import re
-from ..common import get_content, r1, match1, playlist_not_supported
+from ..common import get_content, match1, playlist_not_supported, r1
from ..extractor import VideoExtractor
__all__ = ['cntv_download', 'cntv_download_by_id']
@@ -50,7 +50,7 @@ def cntv_download(url, **kwargs):
re.match(r'http://\w+.cntv.cn/(\w+/)*VIDE\d+.shtml', url) or \
re.match(r'http://(\w+).cntv.cn/(\w+)/classpage/video/(\d+)/(\d+).shtml', url) or \
re.match(r'http(s)?://\w+.cctv.com/\d+/\d+/\d+/\w+.shtml', url) or \
- re.match(r'http://\w+.cntv.cn/\d+/\d+/\d+/\w+.shtml', url):
+ re.match(r'http://\w+.cntv.cn/\d+/\d+/\d+/\w+.shtml', url):
page = get_content(url)
rid = r1(r'videoCenterId","(\w+)"', page)
if rid is None:
diff --git a/src/you_get/extractors/dailymotion.py b/src/you_get/extractors/dailymotion.py
index 789dff45..7ad3cc9c 100644
--- a/src/you_get/extractors/dailymotion.py
+++ b/src/you_get/extractors/dailymotion.py
@@ -2,9 +2,11 @@
__all__ = ['dailymotion_download']
-from ..common import *
import urllib.parse
+from ..common import *
+
+
def rebuilt_url(url):
path = urllib.parse.urlparse(url).path
aid = path.split('/')[-1].split('_')[0]
diff --git a/src/you_get/extractors/douban.py b/src/you_get/extractors/douban.py
index 1a4a67d1..804d6358 100644
--- a/src/you_get/extractors/douban.py
+++ b/src/you_get/extractors/douban.py
@@ -2,9 +2,12 @@
__all__ = ['douban_download']
-import urllib.request, urllib.parse
+import urllib.parse
+import urllib.request
+
from ..common import *
+
def douban_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
html = get_html(url)
@@ -37,13 +40,13 @@ def douban_download(url, output_dir = '.', merge = True, info_only = False, **kw
real_url = resp_data['r']
type, ext, size = url_info(real_url)
print_info(site_info, title, type, size)
- except:
+ except Exception:
pass
if not info_only:
try:
download_urls([real_url], title, ext, size, output_dir, merge = merge)
- except:
+ except Exception:
pass
else:
diff --git a/src/you_get/extractors/douyin.py b/src/you_get/extractors/douyin.py
index 4b60de3c..8b4ce65d 100644
--- a/src/you_get/extractors/douyin.py
+++ b/src/you_get/extractors/douyin.py
@@ -2,16 +2,8 @@
import json
-from ..common import (
- url_size,
- print_info,
- get_content,
- fake_headers,
- download_urls,
- playlist_not_supported,
- match1,
- get_location,
-)
+from ..common import (download_urls, fake_headers, get_content, get_location,
+ match1, playlist_not_supported, print_info, url_size)
__all__ = ['douyin_download_by_url']
@@ -32,7 +24,7 @@ def get_value(source: dict, path):
else:
value = None
break
- except:
+ except Exception:
value = None
return value
diff --git a/src/you_get/extractors/douyutv.py b/src/you_get/extractors/douyutv.py
index 82ea5c4d..3f24573d 100644
--- a/src/you_get/extractors/douyutv.py
+++ b/src/you_get/extractors/douyutv.py
@@ -2,12 +2,13 @@
__all__ = ['douyutv_download']
+import hashlib
+import json
+import re
+import time
+
from ..common import *
from ..util.log import *
-import json
-import hashlib
-import time
-import re
headers = {
'user-agent': 'Mozilla/5.0 (iPad; CPU OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B466 Safari/600.1.4'
diff --git a/src/you_get/extractors/ehow.py b/src/you_get/extractors/ehow.py
index e28527ff..77321c8b 100644
--- a/src/you_get/extractors/ehow.py
+++ b/src/you_get/extractors/ehow.py
@@ -4,34 +4,39 @@ __all__ = ['ehow_download']
from ..common import *
-def ehow_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
-
- assert re.search(r'http://www.ehow.com/video_', url), "URL you entered is not supported"
- html = get_html(url)
- contentid = r1(r'', html)
- vid = r1(r'"demand_ehow_videoid":"([^"]+)"', html)
- assert vid
+def ehow_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
- xml = get_html('http://www.ehow.com/services/video/series.xml?demand_ehow_videoid=%s' % vid)
-
- from xml.dom.minidom import parseString
- doc = parseString(xml)
- tab = doc.getElementsByTagName('related')[0].firstChild
+ assert re.search(r'http://www.ehow.com/video_',
+ url), "URL you entered is not supported"
- for video in tab.childNodes:
- if re.search(contentid, video.attributes['link'].value):
- url = video.attributes['flv'].value
- break
+ html = get_html(url)
+ contentid = r1(
+ r'', html)
+ vid = r1(r'"demand_ehow_videoid":"([^"]+)"', html)
+ assert vid
- title = video.attributes['title'].value
- assert title
+ xml = get_html(
+ 'http://www.ehow.com/services/video/series.xml?demand_ehow_videoid=%s' % vid)
+
+ from xml.dom.minidom import parseString
+ doc = parseString(xml)
+ tab = doc.getElementsByTagName('related')[0].firstChild
+
+ for video in tab.childNodes:
+ if re.search(contentid, video.attributes['link'].value):
+ url = video.attributes['flv'].value
+ break
+
+ title = video.attributes['title'].value
+ assert title
+
+ type, ext, size = url_info(url)
+ print_info(site_info, title, type, size)
+
+ if not info_only:
+ download_urls([url], title, ext, size, output_dir, merge=merge)
- type, ext, size = url_info(url)
- print_info(site_info, title, type, size)
-
- if not info_only:
- download_urls([url], title, ext, size, output_dir, merge = merge)
site_info = "ehow.com"
download = ehow_download
diff --git a/src/you_get/extractors/embed.py b/src/you_get/extractors/embed.py
index aedf5137..8527754a 100644
--- a/src/you_get/extractors/embed.py
+++ b/src/you_get/extractors/embed.py
@@ -3,7 +3,7 @@ __all__ = ['embed_download']
import urllib.parse
from ..common import *
-
+from . import bokecc, iqiyi
from .bilibili import bilibili_download
from .dailymotion import dailymotion_download
from .iqiyi import iqiyi_download_by_vid
@@ -14,8 +14,6 @@ from .sina import sina_download_by_vid
from .tudou import tudou_download_by_id
from .vimeo import vimeo_download_by_id
from .youku import youku_download_by_vid
-from . import iqiyi
-from . import bokecc
"""
refer to http://open.youku.com/tools
diff --git a/src/you_get/extractors/facebook.py b/src/you_get/extractors/facebook.py
index ba8aea8c..e0a2e5e8 100644
--- a/src/you_get/extractors/facebook.py
+++ b/src/you_get/extractors/facebook.py
@@ -2,9 +2,11 @@
__all__ = ['facebook_download']
-from ..common import *
import json
+from ..common import *
+
+
def facebook_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
url = re.sub(r'//.*?facebook.com','//facebook.com',url)
html = get_html(url)
@@ -12,7 +14,7 @@ def facebook_download(url, output_dir='.', merge=True, info_only=False, **kwargs
title = r1(r'(.+)', html)
if title is None:
- title = url
+ title = url
sd_urls = list(set([
unicodize(str.replace(i, '\\/', '/'))
diff --git a/src/you_get/extractors/fc2video.py b/src/you_get/extractors/fc2video.py
index d6f522ce..1c77f09b 100644
--- a/src/you_get/extractors/fc2video.py
+++ b/src/you_get/extractors/fc2video.py
@@ -2,10 +2,12 @@
__all__ = ['fc2video_download']
-from ..common import *
+import re
from hashlib import md5
from urllib.parse import urlparse
-import re
+
+from ..common import *
+
#----------------------------------------------------------------------
def makeMimi(upid):
diff --git a/src/you_get/extractors/flickr.py b/src/you_get/extractors/flickr.py
index 79fca4ff..9d129cd0 100644
--- a/src/you_get/extractors/flickr.py
+++ b/src/you_get/extractors/flickr.py
@@ -2,10 +2,10 @@
__all__ = ['flickr_download_main']
-from ..common import *
-
import json
+from ..common import *
+
pattern_url_photoset = r'https?://www\.flickr\.com/photos/.+/(?:(?:sets)|(?:albums))?/([^/]+)'
pattern_url_photostream = r'https?://www\.flickr\.com/photos/([^/]+)(?:/|(?:/page))?$'
pattern_url_single_photo = r'https?://www\.flickr\.com/photos/[^/]+/(\d+)'
@@ -225,4 +225,4 @@ def get_single_photo_url(url):
site_info = "Flickr.com"
download = flickr_download_main
-download_playlist = playlist_not_supported('flickr');
+download_playlist = playlist_not_supported('flickr')
diff --git a/src/you_get/extractors/freesound.py b/src/you_get/extractors/freesound.py
index a0fe4eec..3b4514cc 100644
--- a/src/you_get/extractors/freesound.py
+++ b/src/you_get/extractors/freesound.py
@@ -4,14 +4,15 @@ __all__ = ['freesound_download']
from ..common import *
+
def freesound_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
page = get_html(url)
-
+
title = r1(r'', html)
if title is None:
- title = url[0]
+ title = url[0]
type, ext, size = url_info(url[0], True)
size = urls_size(url)
diff --git a/src/you_get/extractors/google.py b/src/you_get/extractors/google.py
index c3de296e..6055da02 100644
--- a/src/you_get/extractors/google.py
+++ b/src/you_get/extractors/google.py
@@ -2,10 +2,10 @@
__all__ = ['google_download']
-from ..common import *
-
import re
+from ..common import *
+
# YouTube media encoding options, in descending quality order.
# taken from http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs, 3/22/2013.
youtube_codecs = [
@@ -86,12 +86,14 @@ def google_download(url, output_dir = '.', merge = True, info_only = False, **kw
if response.headers['content-disposition']:
filename = parse.unquote(r1(r'filename="?(.+)"?', response.headers['content-disposition'])).split('.')
title = ''.join(filename[:-1])
- except: pass
+ except Exception:
+ pass
for (i, real_url) in enumerate(real_urls):
title_i = "%s[%s]" % (title, i) if len(real_urls) > 1 else title
type, ext, size = url_info(real_url)
- if ext is None: ext = 'mp4'
+ if ext is None:
+ ext = 'mp4'
print_info(site_info, title_i, ext, size)
if not info_only:
diff --git a/src/you_get/extractors/heavymusic.py b/src/you_get/extractors/heavymusic.py
index c4ced08e..c5c757b8 100644
--- a/src/you_get/extractors/heavymusic.py
+++ b/src/you_get/extractors/heavymusic.py
@@ -4,6 +4,7 @@ __all__ = ['heavymusic_download']
from ..common import *
+
def heavymusic_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
html = get_html(url)
tracks = re.findall(r'href="(online2\.php[^"]+)"', html)
diff --git a/src/you_get/extractors/icourses.py b/src/you_get/extractors/icourses.py
index 606e21e6..e262d057 100644
--- a/src/you_get/extractors/icourses.py
+++ b/src/you_get/extractors/icourses.py
@@ -1,15 +1,16 @@
#!/usr/bin/env python
-from ..common import *
-from urllib import parse, error
-import random
-from time import sleep
+import base64
import datetime
import hashlib
-import base64
import logging
+import random
import re
+from time import sleep
+from urllib import error, parse
from xml.dom.minidom import parseString
+from ..common import *
+
__all__ = ['icourses_download', 'icourses_playlist_download']
@@ -174,7 +175,7 @@ def get_playlist(res_id, course_id):
return re.findall(patt, req)
-class ICousesExactor(object):
+class ICousesExactor():
PLAYER_BASE_VER = '150606-1'
ENCRYPT_MOD_VER = '151020'
ENCRYPT_SALT = '3DAPmXsZ4o' # It took really long time to find this...
diff --git a/src/you_get/extractors/ifeng.py b/src/you_get/extractors/ifeng.py
index 1c66f387..95485f19 100644
--- a/src/you_get/extractors/ifeng.py
+++ b/src/you_get/extractors/ifeng.py
@@ -4,6 +4,7 @@ __all__ = ['ifeng_download', 'ifeng_download_by_id']
from ..common import *
+
def ifeng_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False):
assert r1(r'([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})', id), id
url = 'http://vxml.ifengimg.com/video_info_new/%s/%s/%s.xml' % (id[-2], id[-2:], id)
diff --git a/src/you_get/extractors/imgur.py b/src/you_get/extractors/imgur.py
index d612a30a..f170f027 100644
--- a/src/you_get/extractors/imgur.py
+++ b/src/you_get/extractors/imgur.py
@@ -4,6 +4,7 @@ from ..common import *
from ..extractor import VideoExtractor
from .universal import *
+
class Imgur(VideoExtractor):
name = "Imgur"
diff --git a/src/you_get/extractors/infoq.py b/src/you_get/extractors/infoq.py
index cf8b59e0..dd166e4b 100644
--- a/src/you_get/extractors/infoq.py
+++ b/src/you_get/extractors/infoq.py
@@ -1,9 +1,10 @@
#!/usr/bin/env python
+import ssl
+
from ..common import *
from ..extractor import VideoExtractor
-import ssl
class Infoq(VideoExtractor):
name = "InfoQ"
@@ -23,10 +24,12 @@ class Infoq(VideoExtractor):
sck = match1(content, r'InfoQConstants\.sck\s*=\s*\'([^\']+)\'')
mp3 = match1(content, r'name="filename"\s*value="([^"]+\.mp3)"')
- if mp3: mp3 = 'http://res.infoq.com/downloads/mp3downloads/%s' % mp3
+ if mp3:
+ mp3 = 'http://res.infoq.com/downloads/mp3downloads/%s' % mp3
pdf = match1(content, r'name="filename"\s*value="([^"]+\.pdf)"')
- if pdf: pdf = 'http://res.infoq.com/downloads/pdfdownloads/%s' % pdf
+ if pdf:
+ pdf = 'http://res.infoq.com/downloads/pdfdownloads/%s' % pdf
# cookie handler
ssl_context = request.HTTPSHandler(
@@ -40,9 +43,12 @@ class Infoq(VideoExtractor):
]
request.install_opener(opener)
- if s: self.streams['video'] = {'url': s }
- if mp3: self.streams['audio'] = { 'url': mp3 }
- if pdf: self.streams['slides'] = { 'url': pdf }
+ if s:
+ self.streams['video'] = {'url': s }
+ if mp3:
+ self.streams['audio'] = { 'url': mp3 }
+ if pdf:
+ self.streams['slides'] = { 'url': pdf }
def extract(self, **kwargs):
for i in self.streams:
diff --git a/src/you_get/extractors/instagram.py b/src/you_get/extractors/instagram.py
index 604c534c..b55fab2c 100755
--- a/src/you_get/extractors/instagram.py
+++ b/src/you_get/extractors/instagram.py
@@ -4,6 +4,7 @@ __all__ = ['instagram_download']
from ..common import *
+
def instagram_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
url = r1(r'([^?]*)', url)
cont = get_content(url, headers=fake_headers)
@@ -19,7 +20,7 @@ def instagram_download(url, output_dir='.', merge=True, info_only=False, **kwarg
api_url = 'https://i.instagram.com/api/v1/media/%s/info/' % media_id
try:
api_cont = get_content(api_url, headers={**fake_headers, **{'x-ig-app-id': appId}})
- except:
+ except Exception:
log.wtf('[Error] Please specify a cookie file.')
post = json.loads(api_cont)
diff --git a/src/you_get/extractors/interest.py b/src/you_get/extractors/interest.py
index 9f47e75c..8dbe8803 100644
--- a/src/you_get/extractors/interest.py
+++ b/src/you_get/extractors/interest.py
@@ -1,8 +1,10 @@
#!/usr/bin/env python
-from ..common import *
from json import loads
+from ..common import *
+
+
def interest_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
#http://ch.interest.me/zhtv/VOD/View/114789
#http://program.interest.me/zhtv/sonja/8/Vod/View/15794
@@ -16,7 +18,7 @@ def interest_download(url, output_dir='.', merge=True, info_only=False, **kwargs
serverurl = play_info['data']['cdn']['serverurl']
except KeyError:
raise ValueError('Cannot_Get_Play_URL')
- except:
+ except Exception:
raise ValueError('Cannot_Get_Play_URL')
# I cannot find any example of "fileurl", so i just put it like this for now
assert serverurl
diff --git a/src/you_get/extractors/iqilu.py b/src/you_get/extractors/iqilu.py
index b6d47e24..290dc375 100644
--- a/src/you_get/extractors/iqilu.py
+++ b/src/you_get/extractors/iqilu.py
@@ -2,20 +2,22 @@
__all__ = ['iqilu_download']
-from ..common import *
import json
+from ..common import *
+
+
def iqilu_download(url, output_dir = '.', merge = False, info_only = False, **kwargs):
''''''
if re.match(r'http://v.iqilu.com/\w+', url):
patt = r'url\s*:\s*\[([^\]]+)\]'
-
+
#URL in webpage
html = get_content(url)
player_data = '[' + match1(html, patt) + ']'
urls = json.loads(player_data)
url = urls[0]['stream_url']
-
+
#grab title
title = match1(html, r'0):
+ if len(videos)>0:
for video in videos:
iwara_download(url_first+video, **kwargs)
else:
diff --git a/src/you_get/extractors/ixigua.py b/src/you_get/extractors/ixigua.py
index f2fd953e..e7a8ab99 100644
--- a/src/you_get/extractors/ixigua.py
+++ b/src/you_get/extractors/ixigua.py
@@ -1,15 +1,14 @@
#!/usr/bin/env python
import base64
-
import binascii
-
-from ..common import *
+import ctypes
import random
import string
-import ctypes
from json import loads
from urllib import request
+from ..common import *
+
__all__ = ['ixigua_download', 'ixigua_download_playlist_by_url']
headers = {
diff --git a/src/you_get/extractors/joy.py b/src/you_get/extractors/joy.py
index be37cd50..f031400e 100644
--- a/src/you_get/extractors/joy.py
+++ b/src/you_get/extractors/joy.py
@@ -4,6 +4,7 @@ __all__ = ['joy_download']
from ..common import *
+
def video_info(channel_id, program_id, volumn_id):
url = 'http://msx.app.joy.cn/service.php'
if program_id:
@@ -14,28 +15,28 @@ def video_info(channel_id, program_id, volumn_id):
else:
url += '?action=msxv6'
url += '&videoid=%s' % volumn_id
-
+
xml = get_html(url)
-
+
name = r1(r'(?:)?', xml)
urls = re.findall(r']*>(?:)?', xml)
hostpath = r1(r']*>(?:)?', xml)
-
+
return name, urls, hostpath
def joy_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
channel_id = r1(r'[^_]channelId\s*:\s*"([^\"]+)"', get_html(url))
program_id = r1(r'[^_]programId\s*:\s*"([^\"]+)"', get_html(url))
volumn_id = r1(r'[^_]videoId\s*:\s*"([^\"]+)"', get_html(url))
-
+
title, urls, hostpath = video_info(channel_id, program_id, volumn_id)
urls = [hostpath + url for url in urls]
-
+
size = 0
for url in urls:
_, ext, temp = url_info(url)
size += temp
-
+
print_info(site_info, title, ext, size)
if not info_only:
download_urls(urls, title, ext, size, output_dir = output_dir, merge = merge)
diff --git a/src/you_get/extractors/kakao.py b/src/you_get/extractors/kakao.py
index 4ec282e3..78cfc62f 100644
--- a/src/you_get/extractors/kakao.py
+++ b/src/you_get/extractors/kakao.py
@@ -41,7 +41,7 @@ def kakao_download(url, output_dir='.', info_only=False, **kwargs):
print_info(site_info, title, 'mp4', size)
if not info_only:
download_urls([video_url], title, 'mp4', size, output_dir, **kwargs)
- except:
+ except Exception:
universal_download(url, output_dir, merge=kwargs['merge'], info_only=info_only, **kwargs)
diff --git a/src/you_get/extractors/khan.py b/src/you_get/extractors/khan.py
index e37c8c58..b67895df 100644
--- a/src/you_get/extractors/khan.py
+++ b/src/you_get/extractors/khan.py
@@ -5,6 +5,7 @@ __all__ = ['khan_download']
from ..common import *
from .youtube import YouTube
+
def khan_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
html = get_content(url)
youtube_url = re.search('", page).group(1)
image_url = og_image_url
title = url.split('/')[-1]
diff --git a/src/you_get/extractors/kugou.py b/src/you_get/extractors/kugou.py
index 192bd809..0511abd3 100644
--- a/src/you_get/extractors/kugou.py
+++ b/src/you_get/extractors/kugou.py
@@ -2,11 +2,12 @@
__all__ = ['kugou_download']
-from ..common import *
-from json import loads
-from base64 import b64decode
-import re
import hashlib
+import re
+from base64 import b64decode
+from json import loads
+
+from ..common import *
def kugou_download(url, output_dir=".", merge=True, info_only=False, **kwargs):
@@ -26,7 +27,7 @@ def kugou_download(url, output_dir=".", merge=True, info_only=False, **kwargs):
else:
# for the www.kugou.com/
return kugou_download_playlist(url, output_dir=output_dir, merge=merge, info_only=info_only)
- # raise NotImplementedError(url)
+ # raise NotImplementedError(url)
def kugou_download_by_hash(url, output_dir='.', merge=True, info_only=False):
@@ -41,7 +42,7 @@ def kugou_download_by_hash(url, output_dir='.', merge=True, info_only=False):
url = j['data']['play_url']
title = j['data']['audio_name']
# some songs cann't play because of copyright protection
- if (url == ''):
+ if url == '':
return
songtype, ext, size = url_info(url)
print_info(site_info, title, songtype, size)
@@ -75,7 +76,7 @@ def kugou_download_playlist(url, output_dir='.', merge=True, info_only=False, **
for v in json.loads(res):
urls.append('http://www.kugou.com/song/#hash=%s&album_id=%s' % (v['hash'], v['album_id']))
- # download the playlist
+ # download the playlist
# playlist sample:http://www.kugou.com/yy/special/single/487279.html
else:
html = get_html(url)
diff --git a/src/you_get/extractors/kuwo.py b/src/you_get/extractors/kuwo.py
index 54c09235..0764e9b1 100644
--- a/src/you_get/extractors/kuwo.py
+++ b/src/you_get/extractors/kuwo.py
@@ -2,9 +2,11 @@
__all__ = ['kuwo_download']
-from ..common import *
import re
+from ..common import *
+
+
def kuwo_download_by_rid(rid, output_dir = '.', merge = True, info_only = False):
html=get_content("http://player.kuwo.cn/webmusic/st/getNewMuiseByRid?rid=MUSIC_%s"%rid)
title=match1(html,r"(.*)")
diff --git a/src/you_get/extractors/le.py b/src/you_get/extractors/le.py
index cd5b7a8a..fe708c9b 100644
--- a/src/you_get/extractors/le.py
+++ b/src/you_get/extractors/le.py
@@ -44,7 +44,7 @@ def decode(data):
loc4 = [0] * (2 * length)
for i in range(length):
loc4[2 * i] = loc2[i] >> 4
- loc4[2 * i + 1] = loc2[i] & 15;
+ loc4[2 * i + 1] = loc2[i] & 15
loc6 = loc4[len(loc4) - 11:] + loc4[:len(loc4) - 11]
loc7 = [0] * length
for i in range(length):
diff --git a/src/you_get/extractors/lizhi.py b/src/you_get/extractors/lizhi.py
index 4991df31..a06554fc 100644
--- a/src/you_get/extractors/lizhi.py
+++ b/src/you_get/extractors/lizhi.py
@@ -1,10 +1,12 @@
#!/usr/bin/env python
__all__ = ['lizhi_download']
-import json
import datetime
+import json
+
from ..common import *
+
#
# Worked well but not perfect.
# TODO: add option --format={sd|hd}
diff --git a/src/you_get/extractors/longzhu.py b/src/you_get/extractors/longzhu.py
index 29b340c5..5e5cc9a7 100644
--- a/src/you_get/extractors/longzhu.py
+++ b/src/you_get/extractors/longzhu.py
@@ -3,15 +3,10 @@
__all__ = ['longzhu_download']
import json
-from ..common import (
- get_content,
- general_m3u8_extractor,
- match1,
- print_info,
- download_urls,
- playlist_not_supported,
-)
-from ..common import player
+
+from ..common import (download_urls, general_m3u8_extractor, get_content,
+ match1, player, playlist_not_supported, print_info)
+
def longzhu_download(url, output_dir = '.', merge=True, info_only=False, **kwargs):
web_domain = url.split('/')[2]
diff --git a/src/you_get/extractors/lrts.py b/src/you_get/extractors/lrts.py
index 94d12a25..755c5b64 100644
--- a/src/you_get/extractors/lrts.py
+++ b/src/you_get/extractors/lrts.py
@@ -3,13 +3,16 @@
__all__ = ['lrts_download']
import logging
+
from ..common import *
from ..util import log, term
+
def lrts_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
html = get_html(url)
args = kwargs.get('args')
- if not args: args = {}
+ if not args:
+ args = {}
matched = re.search(r"/book/(\d+)", url)
if not matched:
raise AssertionError("not found book number: %s" % url)
@@ -25,14 +28,14 @@ def lrts_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
total_count = int(matched.group(1))
log.i('%s total: %s' % (book_title, total_count))
first_page = 0
- if ('first' in args and args.first!= None):
+ if ('first' in args and args.first is not None):
first_page = int(args.first)
page_size = 10
- if ('page_size' in args and args.page_size != None):
+ if ('page_size' in args and args.page_size is not None):
page_size = int(args.page_size)
last_page = (total_count // page_size) + 1
- if ('last' in args and args.last != None):
+ if ('last' in args and args.last is not None):
last_page = int(args.last)
log.i('page size is %s, page from %s to %s' % (page_size, first_page, last_page))
diff --git a/src/you_get/extractors/magisto.py b/src/you_get/extractors/magisto.py
index b2e8e502..5b9ba2d2 100644
--- a/src/you_get/extractors/magisto.py
+++ b/src/you_get/extractors/magisto.py
@@ -2,12 +2,14 @@
__all__ = ['magisto_download']
-from ..common import *
import json
+from ..common import *
+
+
def magisto_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
html = get_html(url)
-
+
video_hash = r1(r'video\/([a-zA-Z0-9]+)', url)
api_url = 'https://www.magisto.com/api/video/{}'.format(video_hash)
content = get_html(api_url)
diff --git a/src/you_get/extractors/metacafe.py b/src/you_get/extractors/metacafe.py
index cd5a6e0d..accfd45a 100644
--- a/src/you_get/extractors/metacafe.py
+++ b/src/you_get/extractors/metacafe.py
@@ -2,21 +2,23 @@
__all__ = ['metacafe_download']
-from ..common import *
import urllib.error
from urllib.parse import unquote
+from ..common import *
+
+
def metacafe_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
if re.match(r'http://www.metacafe.com/watch/\w+', url):
html =get_content(url)
title = r1(r' 0:
for k , v in content['data']['rtmp_multi_bitrate'].items():
stream_available[k] = rtmp_url + '/' + v
-
+
for s in self.stream_types:
if s['id'] in stream_available.keys():
quality_id = s['id']
@@ -87,7 +89,7 @@ class QiE(VideoExtractor):
if stream_id not in self.streams:
log.e('[Error] Invalid video format.')
log.e('Run \'-i\' command with no specific video format to view all available formats.')
- exit(2)
+ sys.exit(2)
else:
# Extract stream with the best quality
stream_id = self.streams_sorted[0]['id']
diff --git a/src/you_get/extractors/qie_video.py b/src/you_get/extractors/qie_video.py
index 9cf6ef10..6280b8d1 100644
--- a/src/you_get/extractors/qie_video.py
+++ b/src/you_get/extractors/qie_video.py
@@ -1,9 +1,10 @@
+import json
+import math
+
from ..common import *
from ..extractor import VideoExtractor
from ..util.log import *
-import json
-import math
class QieVideo(VideoExtractor):
name = 'QiE Video'
@@ -71,7 +72,7 @@ def general_m3u8_extractor(url):
result.append(trimmed)
else:
result.append(base_url + '/' + trimmed)
- return result, dur
-
+ return result, dur
+
site = QieVideo()
download_by_url = site.download_by_url
diff --git a/src/you_get/extractors/qq.py b/src/you_get/extractors/qq.py
index e38770e9..fab4a133 100644
--- a/src/you_get/extractors/qq.py
+++ b/src/you_get/extractors/qq.py
@@ -2,9 +2,9 @@
__all__ = ['qq_download']
+from ..common import *
from .qie import download as qieDownload
from .qie_video import download_by_url as qie_video_download
-from ..common import *
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) QQLive/10275340/50192209 Chrome/43.0.2357.134 Safari/537.36 QBCore/3.43.561.202 QQBrowser/9.0.2524.400'
diff --git a/src/you_get/extractors/qq_egame.py b/src/you_get/extractors/qq_egame.py
index c8dca6e0..f25a5faf 100644
--- a/src/you_get/extractors/qq_egame.py
+++ b/src/you_get/extractors/qq_egame.py
@@ -1,5 +1,5 @@
-import re
import json
+import re
from ..common import *
from ..extractors import VideoExtractor
diff --git a/src/you_get/extractors/showroom.py b/src/you_get/extractors/showroom.py
index 606dc806..c49394b1 100644
--- a/src/you_get/extractors/showroom.py
+++ b/src/you_get/extractors/showroom.py
@@ -2,10 +2,12 @@
__all__ = ['showroom_download']
-from ..common import *
import urllib.error
from json import loads
-from time import time, sleep
+from time import sleep, time
+
+from ..common import *
+
#----------------------------------------------------------------------
def showroom_get_roomid_by_room_url_key(room_url_key):
diff --git a/src/you_get/extractors/sina.py b/src/you_get/extractors/sina.py
index bb94d8e3..5cbe5089 100644
--- a/src/you_get/extractors/sina.py
+++ b/src/you_get/extractors/sina.py
@@ -2,14 +2,15 @@
__all__ = ['sina_download', 'sina_download_by_vid', 'sina_download_by_vkey']
-from ..common import *
-from ..util.log import *
-
+import urllib.parse
from hashlib import md5
from random import randint
from time import time
from xml.dom.minidom import parseString
-import urllib.parse
+
+from ..common import *
+from ..util.log import *
+
def api_req(vid):
rand = "0.{0}{1}".format(randint(10000, 10000000), randint(10000, 10000000))
diff --git a/src/you_get/extractors/sohu.py b/src/you_get/extractors/sohu.py
index 74374202..6356d2a9 100644
--- a/src/you_get/extractors/sohu.py
+++ b/src/you_get/extractors/sohu.py
@@ -2,13 +2,13 @@
__all__ = ['sohu_download']
-from ..common import *
-
import json
import time
from random import random
from urllib.parse import urlparse
+from ..common import *
+
'''
Changelog:
1. http://tv.sohu.com/upload/swf/20150604/Main.swf
diff --git a/src/you_get/extractors/soundcloud.py b/src/you_get/extractors/soundcloud.py
index 08e9d561..5d873951 100644
--- a/src/you_get/extractors/soundcloud.py
+++ b/src/you_get/extractors/soundcloud.py
@@ -2,11 +2,12 @@
__all__ = ['sndcd_download']
-from ..common import *
-import re
import json
+import re
import urllib.error
+from ..common import *
+
def get_sndcd_apikey():
home_page = get_content('https://soundcloud.com')
diff --git a/src/you_get/extractors/suntv.py b/src/you_get/extractors/suntv.py
index 0b506440..5502d835 100644
--- a/src/you_get/extractors/suntv.py
+++ b/src/you_get/extractors/suntv.py
@@ -2,17 +2,19 @@
__all__ = ['suntv_download']
-from ..common import *
-import urllib
import re
+import urllib
+
+from ..common import *
+
def suntv_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
if re.match(r'http://www.isuntv.com/\w+', url):
API_URL = "http://www.isuntv.com/ajaxpro/SunTv.pro_vod_playcatemp4,App_Web_playcatemp4.ascx.9f08f04f.ashx"
-
+
itemid = match1(url, r'http://www.isuntv.com/pro/ct(\d+).html')
values = {"itemid" : itemid, "vodid": ""}
-
+
data = str(values).replace("'", '"')
data = data.encode('utf-8')
req = urllib.request.Request(API_URL, data)
@@ -20,17 +22,17 @@ def suntv_download(url, output_dir = '.', merge = True, info_only = False, **kwa
resp = urllib.request.urlopen(req)
respData = resp.read()
respData = respData.decode('ascii').strip('"') #Ahhhhhhh!
-
+
video_url = 'http://www.isuntv.com' + str(respData)
-
+
html = get_content(url, decoded=False)
html = html.decode('gbk')
title = match1(html, '([^<]+)').strip() #get rid of \r\n s
-
+
type_ = ''
size = 0
type, ext, size = url_info(video_url)
-
+
print_info(site_info, title, type, size)
if not info_only:
download_urls([url], title, 'mp4', size, output_dir, merge=merge)
diff --git a/src/you_get/extractors/ted.py b/src/you_get/extractors/ted.py
index c7dd87a1..c4229fe5 100644
--- a/src/you_get/extractors/ted.py
+++ b/src/you_get/extractors/ted.py
@@ -2,9 +2,11 @@
__all__ = ['ted_download']
-from ..common import *
import json
+from ..common import *
+
+
def ted_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
html = get_html(url)
patt = r'"__INITIAL_DATA__"\s*:\s*\{(.+)\}'
diff --git a/src/you_get/extractors/theplatform.py b/src/you_get/extractors/theplatform.py
index c3efb725..bd051dee 100644
--- a/src/you_get/extractors/theplatform.py
+++ b/src/you_get/extractors/theplatform.py
@@ -2,6 +2,7 @@
from ..common import *
+
def theplatform_download_by_pid(pid, title, output_dir='.', merge=True, info_only=False, **kwargs):
smil_url = "http://link.theplatform.com/s/dJ5BDC/%s/meta.smil?format=smil&mbr=true" % pid
smil = get_content(smil_url)
diff --git a/src/you_get/extractors/tiktok.py b/src/you_get/extractors/tiktok.py
index b5a6d4bf..49accaf5 100644
--- a/src/you_get/extractors/tiktok.py
+++ b/src/you_get/extractors/tiktok.py
@@ -4,6 +4,7 @@ __all__ = ['tiktok_download']
from ..common import *
+
def tiktok_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0',
diff --git a/src/you_get/extractors/toutiao.py b/src/you_get/extractors/toutiao.py
index 1c356055..0d4cd169 100644
--- a/src/you_get/extractors/toutiao.py
+++ b/src/you_get/extractors/toutiao.py
@@ -33,7 +33,7 @@ def sign_video_url(vid):
ts=ts)
-class ToutiaoVideoInfo(object):
+class ToutiaoVideoInfo():
def __init__(self):
self.bitrate = None
diff --git a/src/you_get/extractors/tucao.py b/src/you_get/extractors/tucao.py
index 66baa3bf..60068d74 100644
--- a/src/you_get/extractors/tucao.py
+++ b/src/you_get/extractors/tucao.py
@@ -1,11 +1,13 @@
#!/usr/bin/env python
__all__ = ['tucao_download']
-from ..common import *
# import re
import random
import time
from xml.dom import minidom
+
+from ..common import *
+
#possible raw list types
#1. type=tudou&vid=199687639
#2. type=tudou&vid=199506910|
diff --git a/src/you_get/extractors/tudou.py b/src/you_get/extractors/tudou.py
index b1568dfd..92b0d931 100644
--- a/src/you_get/extractors/tudou.py
+++ b/src/you_get/extractors/tudou.py
@@ -2,10 +2,13 @@
__all__ = ['tudou_download', 'tudou_download_playlist', 'tudou_download_by_id', 'tudou_download_by_iid']
-from ..common import *
from xml.dom.minidom import parseString
+
import you_get.extractors.acfun
+from ..common import *
+
+
def tudou_download_by_iid(iid, title, output_dir = '.', merge = True, info_only = False):
data = json.loads(get_decoded_html('http://www.tudou.com/outplay/goto/getItemSegs.action?iid=%s' % iid))
temp = max([data[i] for i in data if 'size' in data[i][0]], key=lambda x:sum([part['size'] for part in x]))
@@ -84,6 +87,7 @@ def parse_playlist(url):
assert aid
assert atitle
import json
+
#url = 'http://www.tudou.com/playlist/service/getZyAlbumItems.html?aid='+aid
url = 'http://www.tudou.com/playlist/service/getAlbumItems.html?aid='+aid
return [(atitle + '-' + x['title'], str(x['itemId'])) for x in json.loads(get_html(url))['message']]
diff --git a/src/you_get/extractors/tumblr.py b/src/you_get/extractors/tumblr.py
index 1fdfcad0..357df9b6 100644
--- a/src/you_get/extractors/tumblr.py
+++ b/src/you_get/extractors/tumblr.py
@@ -3,11 +3,12 @@
__all__ = ['tumblr_download']
from ..common import *
-from .universal import *
from .dailymotion import dailymotion_download
+from .universal import *
from .vimeo import vimeo_download
from .vine import vine_download
+
def tumblr_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
if re.match(r'https?://\d+\.media\.tumblr\.com/', url):
universal_download(url, output_dir, merge=merge, info_only=info_only)
@@ -65,7 +66,7 @@ def tumblr_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
tumblr_id = r1(r'^tumblr_(.+)_\d+$', title) or title
try:
quality = int(r1(r'^tumblr_.+_(\d+)$', title))
- except:
+ except Exception:
quality = int(r1(r'/s(\d+)x\d+/', hd_url))
ext = filename.split('.')[-1]
@@ -79,7 +80,8 @@ def tumblr_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
'ext': ext,
'size': size,
}
- except: pass
+ except Exception:
+ pass
if tuggles:
size = sum([tuggles[t]['size'] for t in tuggles])
@@ -117,7 +119,8 @@ def tumblr_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
real_url = r1(r'