-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·75 lines (67 loc) · 2.33 KB
/
main.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
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
from friends_queue.friends_queue import Config, main
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(
"friends-queue", description="A web interface to queue videos in MPV"
)
parser.add_argument(
"-d", "--debug", action="store_true", help="Enable MPV debug messages"
)
parser.add_argument(
"-s", "--no-search", action="store_true", help="Disable search functionality"
)
parser.add_argument("-l", "--listen", default="0.0.0.0", help="IP to listen on")
parser.add_argument(
"-p", "--port", default=8000, help="Port to listen on", type=int
)
parser.add_argument("--format", help="Override yt-dlp FORMAT SELECTOR")
parser.add_argument(
"--height", help="Max height of video (if --format not used)", type=int
)
parser.add_argument(
"--width", help="Max width of video (if --format not used)", type=int
)
parser.add_argument(
"--vbr", help="Max bitrate of video (if --format not used)", type=int
)
parser.add_argument(
"--abr", help="Max bitrate of audio (if --format not used)", type=int
)
parser.add_argument(
"--fps", help="Max FPS of video (if --format not used)", type=int
)
args = parser.parse_args()
format_str = None
if args.format is not None:
format_str = args.format
elif (
args.height is not None
or args.width is not None
or args.vbr is not None
or args.abr is not None
or args.fps is not None
):
video_args = ""
if args.height is not None:
video_args += f"[height<={args.height}]"
if args.width is not None:
video_args += f"[width<={args.width}]"
if args.vbr is not None:
video_args += f"[vbr<={args.vbr}]"
if args.fps is not None:
video_args += f"[fps<={args.fps}]"
audio_args = ""
if args.abr is not None:
audio_args += f"[abr<={args.abr}]"
format_str = f"bv{video_args}+ba{audio_args}/b{video_args}{audio_args}"
print(f"Using format string: {format_str}")
main(
Config(
debug=args.debug,
search=not args.no_search,
format_specifier=format_str,
host=args.listen,
port=args.port,
)
)