-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream_client
executable file
·38 lines (31 loc) · 1.24 KB
/
stream_client
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
#!/usr/bin/python3
import os
import sys
import argparse
# Force the use of the x11 GDK to allow the use of get_xid
os.environ['GDK_BACKEND'] = 'x11'
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
gi.require_version('WebKit2', '4.0')
from gi.repository import Gtk
from lib import App
parser = argparse.ArgumentParser()
parser.add_argument('stream_id', help='A stream ID, for exemple https://twitch.tv/abcdef or https://www.youtube.com/watch?v=abcdef would both be abcdef')
parser.add_argument('--youtube', '-yt', action='store_true', help='Use the YouTube API instead of the Twitch API')
parser.add_argument('--quality', '-q', default='best', help='The quality of the stream to play')
args = parser.parse_args()
platform = 'twitch' if not args.youtube else 'youtube'
stream_id = args.stream_id
quality = args.quality
print("Starting stream client for %s" % platform)
print("Quality: %s" % quality)
print("Stream: %s" % stream_id)
if __name__ == "__main__":
try:
main = App(stream_id, cookie_storage='{}/.config/stream_client'.format(os.environ['HOME']), quality=quality, platform=platform)
Gtk.main()
except KeyboardInterrupt:
print('Interrupted', file=sys.stderr)
finally:
main.release()