forked from iambus/youku-lixian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
video_lixian.py
executable file
·65 lines (56 loc) · 1.2 KB
/
video_lixian.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
import youku
import bilibili
import acfun
import iask
import ku6
import pptv
import iqiyi
import tudou
import sohu
import w56
import cntv
import yinyuetai
import ifeng
from common import *
import re
def url_to_module(url):
site = r1(r'http://([^/]+)/', url)
assert site, 'invalid url: ' + url
if site.endswith('.com.cn'):
site = site[:-3]
domain = r1(r'(\.[^.]+\.[^.]+)$', site)
assert domain, 'not supported url: ' + url
k = r1(r'([^.]+)', domain)
downloads = {
'youku':youku,
'bilibili':bilibili,
'kankanews':bilibili,
'smgbb':bilibili,
'acfun':acfun,
'iask':iask,
'sina':iask,
'ku6':ku6,
'pptv':pptv,
'iqiyi':iqiyi,
'tudou':tudou,
'sohu':sohu,
'56':w56,
'cntv':cntv,
'yinyuetai':yinyuetai,
'ifeng':ifeng,
}
if k in downloads:
return downloads[k]
else:
raise NotImplementedError(url)
def any_download(url, merge=True):
m = url_to_module(url)
m.download(url, merge=merge)
def any_download_playlist(url, create_dir=False, merge=True):
m = url_to_module(url)
m.download_playlist(url, create_dir=create_dir, merge=merge)
def main():
script_main('video_lixian', any_download, any_download_playlist)
if __name__ == '__main__':
main()