-
Notifications
You must be signed in to change notification settings - Fork 1
/
visitopia-dl.py
40 lines (32 loc) · 983 Bytes
/
visitopia-dl.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
# -*- coding: utf-8 -*-
# author: cgcel
import getopt
import sys
from visitopia import VISTOPIA
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "hu:v", ["help", "url="])
except getopt.GetoptError as err:
# print help information and exit:
print(err) # will print something like "option -a not recognized"
sys.exit(2)
for o, a in opts:
if o == "-v":
verbose = True
elif o in ("-h", "--help"):
print("""使用方法:
python visitopia-dl.py [options]
参数:
-h | --help 获取帮助
-u | --url=<节目链接>""")
sys.exit()
elif o in ("-u", "--url"):
url = a
if 'detail?id' in url:
VISTOPIA().download_all(url=url)
elif 'article?article_id' in url:
VISTOPIA().download_single(url=url)
else:
assert False, "unhandled option"
if __name__ == '__main__':
main()