Beispiel #1
0
    def on_createRoom(self, *args, **kwargs):
        self.roomId = args[0]["roomId"]

        url = "http://%s:5000/client/stream/?roomId=%s"
        if self.ARGS["web"]:
            url = url % (SERVER_ADDR, self.roomId)
        else:
            url = url % (self.ARGS["localIP"], self.roomId)

        platform_dependent(
            f"start \"\" {url.replace('client','host')}", windows=os.system
        )
        platform_dependent(
            f"open \"\" {url.replace('client','host')}", osx=os.system)

        from util import print_url

        print_url(url)

        from util import print_qr, generate_qr

        generate_qr(url)
        if self.ARGS["qr"]:
            print(f"\n[{colored('$','blue')}] Or scan the QR code given below")
            print_qr()
Beispiel #2
0
def initialize(video_paths, server, first=False):
    converted = convert_async(video_paths, args)
    # print("Video paths: ", video_paths, "converted: ", converted)
    if first and converted[0] == (None, None):
        raise ValueError("Invalid video path")

    for video_path, (audio_path, temp_mkv) in zip(video_paths, converted):
        if temp_mkv is not None:
            video_path = temp_mkv
            TO_CLEAR.append(temp_mkv)

        if args.web:
            server.upload(video_path, audio_path)
        else:
            server.addAudioPath(video_path, audio_path)
            TO_CLEAR.append(audio_path)

        platform_dependent(video_path, linux=player.enqueue)

        if first:
            server.create_room()

            def init_player(player):
                player.play()
                player.pause()
                player.seek(0)

            platform_dependent(player, linux=init_player)

        server.add_track(video_path)
    def start_listening(self):
        """ Establish connection to the server and start listening for signals from the server """

        self.signals = SignalReceiver("/", params=self.ARGS)

        platform_dependent(windows=self.signals.bind)

        self.sio.register_namespace(self.signals)
Beispiel #4
0
def exitHandler(*args, **kwargs):
    platform_dependent(
        linux=linux_util.kill_dependencies,
        windows=win_util.kill_dependencies,
        osx=osx_util.kill_dependencies,
    )
    clear_files()
    platform_dependent(linux=linux_util.kill_self,
                       windows=win_util.kill_self,
                       osx=osx_util.kill_self)
Beispiel #5
0
def initialize(videos, server, first=False):
    audio = convert_async(videos, args)

    for video in videos:

        if args.web:
            server.upload(video, video[:-3] + "ogg")
        else:
            server.addAudioPath(video, video[:-3] + "ogg")

        platform_dependent(video, linux=player.enqueue)

        if (first):
            server.create_room()

            def init_player(player):
                player.play()
                player.pause()
                player.seek(0)

            platform_dependent(player, linux=init_player)

        server.add_track(video)
Beispiel #6
0
            try:
                os.remove(file)
            except:
                pass


def exitHandler(*args, **kwargs):
    platform_dependent(linux=linux_util.kill_dependencies,
                       windows=win_util.kill_dependencies)
    clear_files()
    platform_dependent(linux=linux_util.kill_self, windows=win_util.kill_self)


if __name__ == "__main__":

    platform_dependent(windows=freeze_support)

    sys.stdout = Unbuffered(sys.stdout)
    signal.signal(signal.SIGINT, exitHandler)
    colorama.init()
    args = parse()

    platform_dependent(linux=nop if args.web else spawn_server,
                       windows=spawn_server)

    platform_dependent(linux=player.launch)
    server = platform_dependent(args,
                                linux=linux_util.start_server,
                                windows=win_util.start_server)
    platform_dependent(
        linux=Process(target=player.update, args=(server, )).start)
import time

from termcolor import colored
from itertools import product
from multiprocessing import Pool
from urllib.parse import unquote

from util import get_videos, platform_dependent

import linux_util
import win_util
import osx_util

BITRATE = 1000 * 16
ffmpeg = platform_dependent(linux=linux_util.get_ffmpeg,
                            windows=win_util.get_ffmpeg,
                            osx=osx_util.get_ffmpeg)


def path2title(path):
    return path.split("/")[-1:][0]


def get_multiplier(quality):
    """ A multiplier to decide bitrate from the quality string """

    if quality == "low":
        return 5
    elif quality == "medium":
        return 6
    elif quality == "good":
Beispiel #8
0
 def on_seek(self, *args, **kwargs):
     state = args[0]
     platform_dependent(state, linux=self.handle_seek)
Beispiel #9
0
 def on_pause(self, *args, **kwargs):
     platform_dependent(linux=self.handle_pause)