def main(): signal.signal(signal.SIGINT, signal.SIG_DFL) p = ArgumentParser(description="Livestream a single looped input file") p.add_argument('infn', help='file to stream, looping endlessly.') p.add_argument('site', help='site to stream: [youtube,periscope,facebook,twitch]', nargs='?', default='localhost') p.add_argument('-i', '--ini', help='*.ini file with stream parameters', default=R / 'stream.ini') p.add_argument('-y', '--yes', help='no confirmation dialog', action='store_true') P = p.parse_args() site = P.site.split() S = pls.FileIn(P.ini, site, infn=P.infn, loop=True, yes=P.yes) sites: List[str] = list(S.streams.keys()) # %% Go live if P.yes: print(f'going live on {sites} looping file {P.infn}') else: input(f"Press Enter to go live on {sites}," f"looping file {P.infn}") print('Or Ctrl C to abort.') S.golive()
def playonce(flist: List[Path], image: Path, site: str, inifn: Path, shuffle: bool, usemeta: bool, yes: bool): if shuffle: random.shuffle(flist) caption: Union[str, None] for f in flist: if usemeta and TinyTag: try: caption = pls.utils.meta_caption(TinyTag.get(str(f))) print(caption) except LookupError: caption = None else: caption = None s = pls.FileIn(inifn, site, infn=f, loop=False, image=image, caption=caption, yes=yes) s.golive()
def main(): signal.signal(signal.SIGINT, signal.SIG_DFL) p = ArgumentParser(description="Livestream a single looped input file") p.add_argument('infn', help='file to stream, looping endlessly.') p.add_argument( 'websites', help='site to stream, e.g. localhost youtube periscope facebook twitch', nargs='+') p.add_argument('-i', '--ini', help='*.ini file with stream parameters') p.add_argument('-y', '--yes', help='no confirmation dialog', action='store_true') p.add_argument('-t', '--timeout', help='stop streaming after --timeout seconds', type=int) P = p.parse_args() S = pls.FileIn(P.ini, P.websites, infn=P.infn, loop=True, yes=P.yes, timeout=P.timeout) sites: List[str] = list(S.streams.keys()) # %% Go live if P.yes: print(f'going live on {sites} looping file {P.infn}') else: input(f"Press Enter to go live on {sites}," f"looping file {P.infn}") print('Or Ctrl C to abort.') S.golive()
def test_audio(periscope_kbps): flist = list(R.glob('*.ogg')) S = pls.FileIn(inifn=None, websites=sites, infn=flist[0], key='abc') for s in S.streams: assert '-re' in S.streams[s].cmd assert S.streams[s].fps is None
def test_simple(): """stream to localhost """ S = pls.FileIn(inifn=None, websites='youtube', infn=R / 'finished_video.mp4', yes=True, timeout=99999, key='vr6t-wcyh-7g7w-p3q7-fpr4') S.golive()
def test_file_simple(): """stream to localhost""" s = pls.FileIn(inifn, 'localhost', R / 'orch_short.ogg', image=LOGO, yes=True) s.golive()
def test_simple(): """stream to localhost """ with importlib.resources.path( "pylivestream.data", "logo.png" ) as logo, importlib.resources.path("pylivestream.data", "orch_short.ogg") as fn: S = pls.FileIn(inifn=None, websites="localhost", infn=fn, image=logo, yes=True, timeout=5) S.golive()
def test_simple(): """stream to localhost """ S = pls.FileIn(inifn=None, websites='localhost', infn=R / 'orch_short.ogg', image=LOGO, yes=True, timeout=5) S.golive()
def test_filein_audio(): flist = list(R.glob('*.ogg')) S = pls.FileIn(inifn, sites, flist[0], image=LOGO) for s in S.streams: assert '-re' in S.streams[s].cmd assert S.streams[s].fps is None if s == 'periscope': assert S.streams[s].video_kbps == 800 else: assert S.streams[s].video_kbps == 400
def test_filein_video(): S = pls.FileIn(inifn, sites, VIDFN) for s in S.streams: assert '-re' in S.streams[s].cmd assert S.streams[s].fps == approx(24.) if s == 'periscope': assert S.streams[s].video_kbps == 800 else: if int(S.streams[s].res[1]) == 480: assert S.streams[s].video_kbps == 500 elif int(S.streams[s].res[1]) == 720: assert S.streams[s].video_kbps == 1800
def test_props(periscope_kbps): S = pls.FileIn(inifn=None, websites=sites, infn=VIDFN, key='abc') for s in S.streams: assert '-re' in S.streams[s].cmd assert S.streams[s].fps == approx(24.) if s == 'periscope': assert S.streams[s].video_kbps == periscope_kbps else: if int(S.streams[s].res[1]) == 480: assert S.streams[s].video_kbps == 500 elif int(S.streams[s].res[1]) == 720: assert S.streams[s].video_kbps == 1800
def test_audio(periscope_kbps): with importlib.resources.path( "pylivestream.data", "logo.png" ) as logo, importlib.resources.path("pylivestream.data", "orch_short.ogg") as fn: S = pls.FileIn(inifn=None, websites=sites, infn=fn, image=logo, key="abc") for s in S.streams: assert "-re" in S.streams[s].cmd assert S.streams[s].fps is None if s == "periscope": assert S.streams[s].video_kbps == periscope_kbps else: assert S.streams[s].video_kbps == 400
def test_props(periscope_kbps): with importlib.resources.path("pylivestream.data", "bunny.avi") as fn: S = pls.FileIn(inifn=None, websites=sites, infn=fn, key="abc") for s in S.streams: assert "-re" in S.streams[s].cmd assert S.streams[s].fps == approx(24.0) if s == "periscope": assert S.streams[s].video_kbps == periscope_kbps else: if int(S.streams[s].res[1]) == 480: assert S.streams[s].video_kbps == 500 elif int(S.streams[s].res[1]) == 720: assert S.streams[s].video_kbps == 1800
def test_audio(periscope_kbps): flist = list(R.glob("*.ogg")) S = pls.FileIn(inifn=None, websites=sites, infn=flist[0], image=LOGO, key="abc") for s in S.streams: assert "-re" in S.streams[s].cmd assert S.streams[s].fps is None if s == "periscope": assert S.streams[s].video_kbps == periscope_kbps else: assert S.streams[s].video_kbps == 400
def test_audio(): flist = list(R.glob('*.ogg')) S = pls.FileIn(inifn=None, websites=sites, infn=flist[0], image=LOGO, key='abc') for s in S.streams: assert '-re' in S.streams[s].cmd assert S.streams[s].fps is None if s == 'periscope': assert S.streams[s].video_kbps == 800 else: assert S.streams[s].video_kbps == 400
def test_file_simple(): """stream to localhost no listener fixture, to test the other listener """ global skip # not localhost-test, to test the other listener S = pls.FileIn(inifn, 'localhost', R / 'orch_short.ogg', image=LOGO, yes=True) ok = pls.utils.check_display() if not ok: skip = True pytest.skip(f'device display not available') try: S.golive() except RuntimeError as e: skip = True pytest.skip(f'listener error {e}')
def live_stream(): stream = pylivestream.Livestream(inifn=Path(os.getcwd()), site='youtube') stream2 = pylivestream.FileIn(Path(os.getcwd()), websites='youtube') stream.filein() stream.key = 'tusm-dmxq-zp33-2mt2' stream.startlive()