1
1
from pathlib import Path
2
- from getpass import getpass
3
2
import numpy as np
4
3
import subprocess as sp
5
4
import logging ,os ,sys
@@ -86,8 +85,8 @@ def get_resolution(fn:Path) -> tuple:
86
85
# %% top level
87
86
class Stream :
88
87
89
- def __init__ (self ,ini , site , vidsource , image = False ,loop = False ,infn = None ):
90
- self .ini = ini
88
+ def __init__ (self ,ini : Path , site : str , vidsource : str , image : bool = False , loop : bool = False , infn : Path = None ):
89
+ self .ini = Path ( ini ). expanduser ()
91
90
self .site = site
92
91
self .vidsource = vidsource
93
92
self .image = image
@@ -98,6 +97,8 @@ def __init__(self,ini,site,vidsource,image=False,loop=False,infn=None):
98
97
def osparam (self ):
99
98
"""load OS specific config"""
100
99
100
+ assert self .ini .is_file (),'{} not found.' .format (self .ini )
101
+
101
102
C = ConfigParser ()
102
103
C .read (str (self .ini ))
103
104
@@ -200,7 +201,7 @@ def audiocomp(self) -> list:
200
201
'-ar' , self .audiofs ]
201
202
202
203
203
- def video_bitrate (self ) -> list :
204
+ def video_bitrate (self ):
204
205
"""get "best" video bitrate.
205
206
Based on YouTube Live minimum specified stream rate."""
206
207
if self .video_kbps : # per-site override
@@ -304,7 +305,7 @@ class Livestream(Stream):
304
305
def __init__ (self ,ini ,site ,vidsource ,image = False ,loop = False ,infn = None ):
305
306
super ().__init__ (ini ,site ,vidsource ,image ,loop ,infn )
306
307
307
- self .site = site
308
+ self .site = site . lower ()
308
309
309
310
self .osparam ()
310
311
@@ -322,8 +323,7 @@ def __init__(self,ini,site,vidsource,image=False,loop=False,infn=None):
322
323
if self .key :
323
324
streamid = self .key
324
325
else :
325
- print ('\n ' ,' ' .join (cmd ),'\n ' )
326
- streamid = getpass ('{} Live Stream ID: ' .format (self .site ))
326
+ streamid = ''
327
327
328
328
self .sink = [self .server + streamid ]
329
329
@@ -333,7 +333,7 @@ def __init__(self,ini,site,vidsource,image=False,loop=False,infn=None):
333
333
def golive (self , sinks :list = None ):
334
334
"""finally start the stream(s)"""
335
335
336
- if self .sink [ 0 ]. endswith ( 'test' ) :
336
+ if self .key is None :
337
337
print ('\n ' ,' ' .join (self .cmd ),'\n ' )
338
338
return
339
339
@@ -362,9 +362,6 @@ def __init__(self, ini:Path, sites:list):
362
362
if isinstance (sites ,str ):
363
363
sites = [sites ]
364
364
365
- sites = [site .lower () for site in sites ]
366
- ini = Path (ini ).expanduser ()
367
-
368
365
streams = []
369
366
for site in sites :
370
367
print ('Config' ,site )
@@ -388,9 +385,6 @@ def __init__(self, ini:Path, sites:list):
388
385
if isinstance (sites ,str ):
389
386
sites = [sites ]
390
387
391
- sites = [site .lower () for site in sites ]
392
- ini = Path (ini ).expanduser ()
393
-
394
388
streams = []
395
389
for site in sites :
396
390
print ('Config' ,site )
@@ -409,9 +403,7 @@ class FileIn(Livestream):
409
403
410
404
def __init__ (self , ini :Path , site :str , infn :Path , loop :bool = False , image :bool = False ):
411
405
412
- site = site .lower ()
413
406
vidsource = 'file'
414
- ini = Path (ini ).expanduser ()
415
407
416
408
stream = Livestream (ini , site , vidsource , image , loop , infn )
417
409
@@ -428,7 +420,6 @@ def __init__(self, ini:Path, outfn:Path=None, clobber:bool=False):
428
420
"""
429
421
site = 'file'
430
422
vidsource = 'screen'
431
- ini = Path (ini ).expanduser ()
432
423
433
424
super ().__init__ (ini ,site ,vidsource )
434
425
0 commit comments