Example #1
0
    def get_torrent(name, season=None, episode=None):
        interface = get_interface()
        settings = get_settings()
        path = abspath(__file__)
        dir_path = dirname(path)
        exec_ = join(dir_path, "..", "main.py")
        command = '%s %s \"%s\" ' % (py_exec, exec_, name)
        if season is not None:
            command += "%s %s " % (season, episode)
        lock = Lock(LOCK_FILE)
        if lock.is_same_file(name, season, episode) and \
                is_process_running(lock.get_pid()):
            data = lock._get_file_data()
            port = data[4]
        else:
            if settings.force_ts_proxy_port:
                port = settings.ts_proxy_port
            else:
                port = get_free_port()
            command += "--daemon --port %s " % port
            log.info(command)
            process = Popen(command, shell=True, stdout=PIPE, stderr=STDOUT)
            sleep(1)

        redirect_url = "http://%s:%s" % (interface, port)
        serving = False
        while not serving:
            try:
                req = requests.get("%s/status" % redirect_url)
                serving = True
            except requests.ConnectionError, e:
                sleep(1)
Example #2
0
    def get_torrent(name, season=None, episode=None):
        interface = get_interface()
        path = abspath(__file__)
        dir_path = dirname(path)
        exec_ = join(dir_path, "__init__.py")
        command = '%s %s \"%s\" ' % (py_exec, exec_, name)
        if season is not None:
            command += "%s %s " % (season, episode)
        lock = Lock(LOCKFILE)
        if lock.is_same_file(name, season, episode) and \
                is_process_running(lock.get_pid()):
            data = lock._get_file_data()
            port = data[4]
        else:
            port = get_free_port()
            command += "--daemon --port %s " % port
            log.debug(command)
            process = Popen(command, shell=True, stdout=PIPE, stderr=STDOUT)
            sleep(1)

        redirect_url = "http://%s:%s" % (interface, port)
        serving = False
        while not serving:
            try:
                req = requests.get("%s/status" % redirect_url)
                serving = True
            except requests.ConnectionError, e:
                sleep(1)
Example #3
0
 def run(self):
     chromecast = self.parent.chromecast
     device = pychromecast.get_chromecast(friendly_name=chromecast)
     interface = get_interface()
     guess = self.parent.guess(self.parent.get_video_path())
     device.play_media("http://%s:%s" % (interface, self.parent.port),
                       guess['mimetype'])
     while True:
         sleep(1)
Example #4
0
    def list_(name, season, episode):
        url = "http://%s:5000/%s/%s" % (get_interface(), name, season)
        episode = int(episode)

        template = app.jinja_env.get_template("m3u.j2")
        ret = template.render(episodes=range(episode, episode + 10),
                              series=name, season=episode, url=url)
        return Response(response=ret, status=200,
                        mimetype="application/x-mpegurl",
                        content_type="application/x-mpegurl")
Example #5
0
    def run(self):
        import pychromecast

        self.chromecast = pychromecast.get_chromecast()
        interface = get_interface()
        guess = self.parent.guess(self.parent.get_video_path())
        self.chromecast.play_media("http://%s:%s" % (interface, self.parent.port),
                                   guess['mimetype'])
        while True:
            sleep(1)
Example #6
0
    def run(self):
        import pychromecast

        self.chromecast = pychromecast.get_chromecast()
        interface = get_interface()
        guess = self.parent.guess(self.parent.get_video_path())
        self.chromecast.play_media(
            "http://%s:%s" % (interface, self.parent.port), guess['mimetype'])
        while True:
            sleep(1)
Example #7
0
    def list_(name, season, episode):
        url = "http://%s:5000/%s/%s" % (get_interface(), name, season)
        episode = int(episode)

        template = app.jinja_env.get_template("m3u.j2")
        ret = template.render(episodes=range(episode, episode + 10),
                              series=name,
                              season=episode,
                              url=url)
        return Response(response=ret,
                        status=200,
                        mimetype="application/x-mpegurl",
                        content_type="application/x-mpegurl")
Example #8
0
    def redirect_to(name, season=None, episode=None):
        log.info("Requesting %s %s %s", name, season, episode)
        interface = get_interface()
        path = abspath(__file__)
        dir_path = dirname(path)
        exec_ = join(dir_path, "__init__.py")

        port = "8890"#get_free_port()

        command = '%s %s \"%s\" ' % (py_exec, exec_, name)
        if season is not None:
            command += "%s %s " % (season, episode)
        command += "--daemon --port %s " % port
        log.debug(command)
        process = Popen(command, shell=True, stdout=PIPE, stderr=STDOUT)
        sleep(1)
        while get_lock_diff() < 30:
            sleep(1)
        redirect_url = "http://%s:%s" % (interface, port)
        log.info("redirecting to %s" % redirect_url)
        return redirect(redirect_url)