def Push(self, handler, query): try: tsn = query['tsn'][0] except: logger.error('Push requires a TiVo Service Number') handler.send_error(404) return if not tsn in config.tivos: for key, value in config.tivos.items(): if value.get('name') == tsn: tsn = key break try: tivo_name = config.tivos[tsn]['name'] except: tivo_name = tsn container = quote(query['Container'][0].split('/')[0]) ip = config.get_ip(tsn) port = config.getPort() baseurl = 'http://%s:%s/%s' % (ip, port, container) if config.getIsExternal(tsn): exturl = config.get_server('externalurl') if exturl: if not exturl.endswith('/'): exturl += '/' baseurl = exturl + container else: ip = self.readip() baseurl = 'http://%s:%s/%s' % (ip, port, container) path = self.get_local_base_path(handler, query) files = query.get('File', []) for f in files: file_path = os.path.normpath(path + '/' + f) queue.append({ 'path': file_path, 'name': f, 'tsn': tsn, 'url': baseurl }) if len(queue) == 1: thread.start_new_thread(Video.process_queue, (self, )) logger.info('[%s] Queued "%s" for Push to %s' % (time.strftime('%d/%b/%Y %H:%M:%S'), unicode(file_path, 'utf-8'), tivo_name)) files = [unicode(f, 'utf-8') for f in files] handler.redir(PUSHED % (tivo_name, '<br>'.join(files)), 5)
def Push(self, handler, query): try: tsn = query['tsn'][0] except: logger.error('Push requires a TiVo Service Number') handler.send_error(404) return if not tsn in config.tivos: for key, value in config.tivos.items(): if value.get('name') == tsn: tsn = key break try: tivo_name = config.tivos[tsn]['name'] except: tivo_name = tsn container = quote(query['Container'][0].split('/')[0]) ip = config.get_ip(tsn) port = config.getPort() baseurl = 'http://%s:%s/%s' % (ip, port, container) if config.getIsExternal(tsn): exturl = config.get_server('externalurl') if exturl: if not exturl.endswith('/'): exturl += '/' baseurl = exturl + container else: ip = self.readip() baseurl = 'http://%s:%s/%s' % (ip, port, container) path = self.get_local_base_path(handler, query) files = query.get('File', []) for f in files: file_path = os.path.normpath(path + '/' + f) queue.append({'path': file_path, 'name': f, 'tsn': tsn, 'url': baseurl}) if len(queue) == 1: thread.start_new_thread(Video.process_queue, (self,)) logger.info('[%s] Queued "%s" for Push to %s' % (time.strftime('%d/%b/%Y %H:%M:%S'), unicode(file_path, 'utf-8'), tivo_name)) files = [unicode(f, 'utf-8') for f in files] handler.redir(PUSHED % (tivo_name, '<br>'.join(files)), 5)
def Push(self, handler, query): tsn = query['tsn'][0] for key in config.tivo_names: if config.tivo_names[key] == tsn: tsn = key break tivo_name = config.tivo_names.get(tsn, tsn) container = quote(query['Container'][0].split('/')[0]) ip = config.get_ip(tsn) port = config.getPort() baseurl = 'http://%s:%s/%s' % (ip, port, container) if config.getIsExternal(tsn): exturl = config.get_server('externalurl') if exturl: baseurl = exturl else: ip = self.readip() baseurl = 'http://%s:%s/%s' % (ip, port, container) path = self.get_local_base_path(handler, query) files = query.get('File', []) for f in files: file_path = path + os.path.normpath(f) queue.append({ 'path': file_path, 'name': f, 'tsn': tsn, 'url': baseurl }) if len(queue) == 1: thread.start_new_thread(Video.process_queue, (self, )) logger.info('[%s] Queued "%s" for Push to %s' % (time.strftime('%d/%b/%Y %H:%M:%S'), unicode(file_path, 'utf-8'), tivo_name)) files = [unicode(f, 'utf-8') for f in files] handler.redir(PUSHED % (tivo_name, '<br>'.join(files)), 5)
def Push(self, handler, query): tsn = query['tsn'][0] for key in config.tivo_names: if config.tivo_names[key] == tsn: tsn = key break tivo_name = config.tivo_names.get(tsn, tsn) container = quote(query['Container'][0].split('/')[0]) ip = config.get_ip(tsn) port = config.getPort() baseurl = 'http://%s:%s/%s' % (ip, port, container) if config.getIsExternal(tsn): exturl = config.get_server('externalurl') if exturl: if not exturl.endswith('/'): exturl += '/' baseurl = exturl + container else: ip = self.readip() baseurl = 'http://%s:%s/%s' % (ip, port, container) path = self.get_local_base_path(handler, query) files = query.get('File', []) for f in files: file_path = path + os.path.normpath(f) queue.append({'path': file_path, 'name': f, 'tsn': tsn, 'url': baseurl}) if len(queue) == 1: thread.start_new_thread(Video.process_queue, (self,)) logger.info('[%s] Queued "%s" for Push to %s' % (time.strftime('%d/%b/%Y %H:%M:%S'), unicode(file_path, 'utf-8'), tivo_name)) files = [unicode(f, 'utf-8') for f in files] handler.redir(PUSHED % (tivo_name, '<br>'.join(files)), 5)
def Push(self, handler, query): tsn = query["tsn"][0] for key in config.tivo_names: if config.tivo_names[key] == tsn: tsn = key break tivo_name = config.tivo_names.get(tsn, tsn) container = quote(query["Container"][0].split("/")[0]) ip = config.get_ip(tsn) port = config.getPort() baseurl = "http://%s:%s/%s" % (ip, port, container) if config.getIsExternal(tsn): exturl = config.get_server("externalurl") if exturl: if not exturl.endswith("/"): exturl += "/" baseurl = exturl + container else: ip = self.readip() baseurl = "http://%s:%s/%s" % (ip, port, container) path = self.get_local_base_path(handler, query) files = query.get("File", []) for f in files: file_path = path + os.path.normpath(f) queue.append({"path": file_path, "name": f, "tsn": tsn, "url": baseurl}) if len(queue) == 1: thread.start_new_thread(Video.process_queue, (self,)) logger.info( '[%s] Queued "%s" for Push to %s' % (time.strftime("%d/%b/%Y %H:%M:%S"), unicode(file_path, "utf-8"), tivo_name) ) files = [unicode(f, "utf-8") for f in files] handler.redir(PUSHED % (tivo_name, "<br>".join(files)), 5)
def Push(self, handler, query): tsn = query['tsn'][0] for key in config.tivo_names: if config.tivo_names[key] == tsn: tsn = key break tivo_name = config.tivo_names.get(tsn, tsn) container = quote(query['Container'][0].split('/')[0]) ip = config.get_ip() port = config.getPort() baseurl = 'http://%s:%s' % (ip, port) if config.getIsExternal(tsn): exturl = config.get_server('externalurl') if exturl: baseurl = exturl else: ip = self.readip() baseurl = 'http://%s:%s' % (ip, port) path = self.get_local_base_path(handler, query) files = query.get('File', []) for f in files: file_path = path + os.path.normpath(f) file_info = VideoDetails() file_info['valid'] = transcode.supported_format(file_path) mime = 'video/mpeg' if config.isHDtivo(tsn): for m in ['video/mp4', 'video/bif']: if transcode.tivo_compatible(file_path, tsn, m)[0]: mime = m break if file_info['valid']: file_info.update(self.metadata_full(file_path, tsn, mime)) url = baseurl + '/%s%s' % (container, quote(f)) title = file_info['seriesTitle'] if not title: title = file_info['title'] source = file_info['seriesId'] if not source: source = title subtitle = file_info['episodeTitle'] try: m = mind.getMind(tsn) m.pushVideo( tsn = tsn, url = url, description = file_info['description'], duration = file_info['duration'] / 1000, size = file_info['size'], title = title, subtitle = subtitle, source = source, mime = mime, tvrating = file_info['tvRating']) except Exception, e: handler.send_response(500) handler.end_headers() handler.wfile.write('%s\n\n%s' % (e, traceback.format_exc() )) raise logger.info('[%s] Queued "%s" for Push to %s' % (time.strftime('%d/%b/%Y %H:%M:%S'), unicode(file_path, 'utf-8'), tivo_name))