def init(self): # Check the progress and decide the download cmd self.video.playUrl = "/tmp/all.ts" if len(self.video.sections) <= 1: # Unsplitted file if self.video.progress <= 30: urls, delta = self.getUrls() self.video.downloader = MultiDownloader(urls, alternativeUrls=self.video.alternativeUrls) self.video.downloader.getSizeInfo() self.video.download_args = '%s > %s 2>/tmp/cat.log' % (self.video.downloader.getCatCmds()[0], self.video.playUrl) else: self.video.downloader = None self.video.download_args = self.getFfmpegCmd(self.video.progress, self.getUrls()[0][0], self.video.playUrl) else: # Splitted file urls, delta = self.getUrls() self.video.downloader = MultiDownloader(urls, alternativeUrls=self.video.alternativeUrls) self.video.downloader.getSizeInfo() catCmds = self.video.downloader.getCatCmds() ffmpeg_part = "/tmp/ffmpeg_part" p_list = [] download_lines = [] for idx, catCmd in enumerate(catCmds): pname = os.path.join(ffmpeg_part, str(idx)) newFifo(pname) if idx == 0 and delta > 30: download_lines.append("{\n%s | %s\n}" % (catCmd, self.getFfmpegCmd(delta, "-", pname))) else: download_lines.append("{\n%s | %s\n}" % (catCmd, self.getFfmpegCmd(0, "-", pname))) p_list.append(pname) ffmpeg_input = " ".join(p_list) download_args = 'cat %s | ffmpeg -f mpegts -i - -c copy -y -f mpegts %s 2> /tmp/merge.log &\n' \ % (ffmpeg_input, self.video.playUrl) download_args += " && ".join(download_lines) self.video.download_args = download_args
if current_website == 'youku' and request.url.startswith("/search_video"): redirectTo = "%s?site=%s&url=%s" % ( '/forward', current_website, urllib2.quote( request.url.replace(to_replace, "http://www.soku.com"))) logging.debug("Redirect to %s", redirectTo) response.set_header('location', redirectTo) response.status = 303 @error(500) def error500(error): return ("Exception: %s\nDetails: %s" % (error.exception, error.traceback)).replace('\n', '<br>') newFifo('/tmp/cmd') newFifo('/tmp/all.ts') newDir('/tmp/ffmpeg_part') newDir('/tmp/download_part') for i in range(1000): newFifo('/tmp/download_part/%s' % i) try: if sys.platform == 'darwin': run(host='0.0.0.0', port=7777, reloader=True) else: run(host='0.0.0.0', port=80, quiet=True) except: logging.exception("Exception catched")
websites[current_website]['url']))) if current_website == 'youku' and request.url.startswith("/search_video"): redirectTo = "%s?site=%s&url=%s" % ('/forward', current_website, urllib2.quote(request.url.replace(to_replace, "http://www.soku.com"))) logging.debug("Redirect to %s", redirectTo) response.set_header('location', redirectTo) response.status = 303 @error(500) def error500(error): return ("Exception: %s\nDetails: %s" % (error.exception, error.traceback)).replace('\n', '<br>') newFifo('/tmp/cmd') newFifo('/tmp/all.ts') newDir('/tmp/ffmpeg_part') newDir('/tmp/download_part') for i in range(1000): newFifo('/tmp/download_part/%s' % i) try: if sys.platform == 'darwin': run(host='0.0.0.0', port=7777, reloader=True) else: run(host='0.0.0.0', port=80, quiet=True) except: logging.exception("Exception catched")