forked from allejok96/jw-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjwb-stream
More file actions
executable file
·58 lines (48 loc) · 1.61 KB
/
jwb-stream
File metadata and controls
executable file
·58 lines (48 loc) · 1.61 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
#!/usr/bin/env python3
import random
import subprocess
from jwlib.arguments import ArgumentParser, Settings
from jwlib.parse import parse_broadcasting, Media
parser = ArgumentParser(prog='jwb-stream',
usage='%(prog)s [options] [DIR]',
description='Stream videos from jw.org')
parser.add_arguments(['--lang',
'--languages',
'--quality',
'--hard-subtitles',
'--category',
'--exclude',
'--latest',
'--since',
'--forever',
'command'])
settings = Settings()
# Default starting point
settings.include_categories = ('VODStudio',)
parser.parse_args(namespace=settings)
if not settings.command:
raise RuntimeError("Not enough arguments")
while True:
# Do the indexing
data = parse_broadcasting(settings)
if not data:
exit()
# All unique
links = set()
for category in data:
for item in category.contents:
if isinstance(item, Media):
print(item.name)
if item.exists_in('.'):
# Use local files if available
links.add(item.filename)
else:
links.add(item.url)
links = list(links)
random.shuffle(links)
# Avoid too long argument string (win) or too manny arguments (unix)
while links:
subprocess.check_call(settings.command + links[:300])
links = links[300:]
if not settings.stream_forever:
break