-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoviedl.py
More file actions
62 lines (42 loc) · 2.68 KB
/
Copy pathmoviedl.py
File metadata and controls
62 lines (42 loc) · 2.68 KB
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
import argparse
from providers import get_appropriate
import requests
from cli.helpers import *
from cli.search import search
from cli.download import cli_download
def __movie_dl__():
session = requests.Session()
parser = argparse.ArgumentParser(description="movie-dl is a high quality movie/series download and/or grabber.")
parser.add_argument('-s', '--search', required=False, default='', help="Query for searching from WatchSeries.")
parser.add_argument('--iafl', action="store_true", help="'I am feeling lucky' mode, that is, the first result (if search is used) will be enqueued for download.")
parser.add_argument('-dl', '--download', required=False, default='', help="Download from a valid url.")
parser.add_argument('-l', '--list', required=False, default='', help="Selections of episode (if series).")
parser.add_argument('-o', '--output-folder', required=False, default='', help="Folder to which the content would be downloaded.")
parser.add_argument('-g', '--grab', required=False, default='', help="Grab the stream link(s) without downloading.")
parser.add_argument('-q', '--quiet', action="store_true", help="Quiet mode, basically for disabling tqdm.")
parsed = parser.parse_args()
dl_check = get_check(parsed.list)
if parsed.search:
print("Searching for '%s' on WatchSeries:" % parsed.search)
results = [*search(session, parsed.search)]
if not results:
print("Could not find anything from that identifier.")
for index, content in enumerate(results, 1):
print("{0:02d}: {name} \x1b[33m{url}\x1b[0m".format(index, **content))
if not parsed.iafl:
return
if not results:
return print("'I am feeling lucky' cannot continue since there are no results.")
first_result = results.pop(0)
url = first_result.get('url')
for qualities in get_appropriate(session, url, check=dl_check):
cli_download(session, qualities, first_result.get('name'), parsed.quiet)
if parsed.download:
for qualities in get_appropriate(session, parsed.download, check=dl_check):
cli_download(session, qualities, parsed.output_folder or 'Downloads', parsed.quiet)
if parsed.grab:
for qualities in get_appropriate(session, parsed.grab, check=dl_check):
print(', '.join(q.get('stream_url') for q in qualities))
print("Headers for above stream(s): %s" % ', '.join("%s" % q.get('headers', {}) for q in qualities))
if __name__ == '__main__':
__movie_dl__()