18
18
19
19
20
20
def watch_chromecast (args , m : dict , subtitles_file = None ) -> Optional [subprocess .CompletedProcess ]:
21
- if "vlc" in args .player :
21
+ if "vlc" in m ["player" ]:
22
+ subtitles = ["--sub-file=" + subtitles_file ] if subtitles_file else []
22
23
catt_log = processes .cmd (
23
24
"vlc" ,
24
25
"--sout" ,
25
26
"#chromecast" ,
26
27
f"--sout-chromecast-ip={ args .cc_ip } " ,
27
28
"--demux-filter=demux_chromecast" ,
28
- "--sub-file=" + subtitles_file if subtitles_file else "" ,
29
- * args . player [1 :],
29
+ * subtitles ,
30
+ * m [ " player" ] [1 :],
30
31
m ["path" ],
31
32
)
32
33
else :
33
34
if args .action in (SC .watch , SC .listen ):
35
+ subtitles = ["-s" , subtitles_file ] if subtitles_file else ["--no-subs" ]
34
36
catt_log = processes .cmd (
35
37
"catt" ,
36
38
"-d" ,
37
39
args .chromecast_device ,
38
40
"cast" ,
39
- "-s" ,
40
- subtitles_file if subtitles_file else consts .FAKE_SUBTITLE ,
41
+ * subtitles ,
41
42
m ["path" ],
42
43
)
43
44
else :
@@ -90,7 +91,6 @@ def calculate_duration(args, m) -> Tuple[int, int]:
90
91
91
92
def listen_chromecast (args , m : dict ) -> Optional [subprocess .CompletedProcess ]:
92
93
Path (consts .CAST_NOW_PLAYING ).write_text (m ["path" ])
93
- Path (consts .FAKE_SUBTITLE ).touch ()
94
94
catt = which ("catt" ) or "catt"
95
95
start , end = calculate_duration (args , m )
96
96
@@ -101,8 +101,7 @@ def listen_chromecast(args, m: dict) -> Optional[subprocess.CompletedProcess]:
101
101
"-d" ,
102
102
args .chromecast_device ,
103
103
"cast" ,
104
- "-s" ,
105
- consts .FAKE_SUBTITLE ,
104
+ "--no-subs" ,
106
105
"--block" ,
107
106
"--seek-to" ,
108
107
str (start ),
@@ -124,8 +123,7 @@ def listen_chromecast(args, m: dict) -> Optional[subprocess.CompletedProcess]:
124
123
"-d" ,
125
124
args .chromecast_device ,
126
125
"cast" ,
127
- "-s" ,
128
- consts .FAKE_SUBTITLE ,
126
+ "--no-subs" ,
129
127
"--block" ,
130
128
"--seek-to" ,
131
129
str (start ),
@@ -184,7 +182,7 @@ def transcode(args, path) -> str:
184
182
video_settings = ["-c:v" , "copy" ]
185
183
186
184
print ("Transcoding" , temp_video )
187
- processes .cmd_interactive (
185
+ r = processes .cmd_interactive (
188
186
"ffmpeg" ,
189
187
"-nostdin" ,
190
188
"-loglevel" ,
@@ -205,11 +203,14 @@ def transcode(args, path) -> str:
205
203
temp_video ,
206
204
)
207
205
208
- Path (path ).unlink ()
209
- shutil .move (temp_video , transcode_dest )
210
- with args .db .conn :
211
- args .db .conn .execute ("UPDATE media SET path = ? where path = ?" , [transcode_dest , path ])
212
- return transcode_dest
206
+ if Path (temp_video ).exists ():
207
+ Path (path ).unlink ()
208
+ shutil .move (temp_video , transcode_dest )
209
+ with args .db .conn :
210
+ args .db .conn .execute ("UPDATE media SET path = ? where path = ?" , [transcode_dest , path ])
211
+ return transcode_dest
212
+ else :
213
+ return path
213
214
214
215
215
216
def get_browser () -> Optional [str ]:
@@ -524,7 +525,7 @@ def single_player(args, m):
524
525
if system () == "Windows" or args .action in (SC .watch ):
525
526
r = processes .cmd (* m ["player" ], m ["path" ], strict = False )
526
527
else : # args.action in (SC.listen)
527
- r = processes .cmd_interactive (* m ["player" ], m ["path" ])
528
+ r = processes .cmd_interactive (* m ["player" ], m ["path" ], strict = False )
528
529
529
530
if m ["player_need_sleep" ]:
530
531
try :
0 commit comments