Beispiel #1
0
    def get_tivo_file(self, tivoIP, url, mak, togo_path):
        # global status
        status[url].update({'running': True, 'queued': False})

        parse_url = urlparse.urlparse(url)

        name = unquote(parse_url[2])[10:].split('.')
        id = unquote(parse_url[4]).split('id=')[1]
        name.insert(-1, ' - ' + id + '.')
        if status[url]['decode']:
            name[-1] = 'mpg'
        outfile = os.path.join(togo_path, ''.join(name))

        if status[url]['save']:
            meta = basic_meta[url]
            details_url = 'https://%s/TiVoVideoDetails?id=%s' % (tivoIP, id)
            try:
                handle = self.tivo_open(details_url)
                meta.update(metadata.from_details(handle))
                handle.close()
            except:
                pass
            metafile = open(outfile + '.txt', 'w')
            metadata.dump(metafile, meta)
            metafile.close()

        auth_handler.add_password('TiVo DVR', url, 'tivo', mak)
        try:
            handle = self.tivo_open(url)
        except urllib2.HTTPError, e:
            status[url]['running'] = False
            status[url]['error'] = e.code
            logger.error(e.code)
            return
Beispiel #2
0
    def get_tivo_file(self, tivoIP, url, mak, togo_path):
        # global status
        status[url].update({'running': True, 'queued': False})

        parse_url = urlparse.urlparse(url)

        name = unquote(parse_url[2])[10:].split('.')
        id = unquote(parse_url[4]).split('id=')[1]
        name.insert(-1, ' - ' + id + '.')
        if status[url]['decode']:
            name[-1] = 'mpg'
        outfile = os.path.join(togo_path, ''.join(name))

        if status[url]['save']:
            meta = basic_meta[url]
            details_url = 'https://%s/TiVoVideoDetails?id=%s' % (tivoIP, id)
            try:
                handle = self.tivo_open(details_url)
                meta.update(metadata.from_details(handle))
                handle.close()
            except:
                pass
            metafile = open(outfile + '.txt', 'w')
            metadata.dump(metafile, meta)
            metafile.close()

        auth_handler.add_password('TiVo DVR', url, 'tivo', mak)
        try:
            handle = self.tivo_open(url)
        except urllib2.HTTPError, e:
            status[url]['running'] = False
            status[url]['error'] = e.code
            logger.error(e.code)
            return
Beispiel #3
0
    def get_tivo_file(self, tivoIP, url, mak, togo_path):
        # global status
        status[url].update({'running': True, 'queued': False})

        parse_url = urlparse.urlparse(url)

        if status[url]['save']:
            meta = basic_meta[url]

        name = unicode(unquote(parse_url[2]),
                       'utf-8').split('/')[-1].split('.')
        try:
            name.insert(-1, ' - ' + meta['episodeTitle'])
        except:
            pass
        ts = status[url]['ts_format']
        if status[url]['decode']:
            if ts:
                name[-1] = 'ts'
            else:
                name[-1] = 'mpg'
        else:
            if ts:
                name.insert(-1, ' (TS)')
            else:
                name.insert(-1, ' (PS)')
        name.insert(-1, '.')
        name = ''.join(name)
        for ch in BADCHAR:
            name = name.replace(ch, BADCHAR[ch])
        outfile = os.path.join(togo_path, name)

        if status[url]['save']:
            meta = basic_meta[url]
            try:
                handle = self.tivo_open(details_urls[url])
                meta.update(metadata.from_details(handle.read()))
                handle.close()
            except:
                pass
            metafile = open(outfile + '.txt', 'w')
            metadata.dump(metafile, meta)
            metafile.close()

        auth_handler.add_password('TiVo DVR', url, 'tivo', mak)
        try:
            if status[url]['ts_format']:
                handle = self.tivo_open(url + '&Format=video/x-tivo-mpeg-ts')
            else:
                handle = self.tivo_open(url)
        except Exception, msg:
            status[url]['running'] = False
            status[url]['error'] = str(msg)
            return
Beispiel #4
0
    def get_tivo_file(self, tivoIP, url, mak, togo_path):
        # global status
        status[url].update({'running': True, 'queued': False})

        parse_url = urlparse.urlparse(url)

        name = unicode(unquote(parse_url[2]), 'utf-8').split('/')[-1].split('.')
        try:
            id = unquote(parse_url[4]).split('id=')[1]
            name.insert(-1, ' - ' + id)
        except:
            pass
        ts = status[url]['ts_format']
        if status[url]['decode']:
            if ts:
                name[-1] = 'ts'
            else:
                name[-1] = 'mpg'
        else:
            if ts:
                name.insert(-1, ' (TS)')
            else:
                name.insert(-1, ' (PS)')
        name.insert(-1, '.')
        name = ''.join(name)
        for ch in BADCHAR:
            name = name.replace(ch, BADCHAR[ch])
        outfile = os.path.join(togo_path, name)

        if status[url]['save']:
            meta = basic_meta[url]
            try:
                handle = self.tivo_open(details_urls[url])
                meta.update(metadata.from_details(handle.read()))
                handle.close()
            except:
                pass
            metafile = open(outfile + '.txt', 'w')
            metadata.dump(metafile, meta)
            metafile.close()

        auth_handler.add_password('TiVo DVR', url, 'tivo', mak)
        try:
            if status[url]['ts_format']:
                handle = self.tivo_open(url + '&Format=video/x-tivo-mpeg-ts')
            else:
                handle = self.tivo_open(url)
        except Exception, msg:
            status[url]['running'] = False
            status[url]['error'] = str(msg)
            return
Beispiel #5
0
                    outfile_name.insert(-1, '.')
                    new_outfile = ''.join(outfile_name)
                    if os.path.isfile(new_outfile):
                        count += 1
                        continue

                    os.rename(outfile, new_outfile)
                    outfile = new_outfile
                    break

            if save_txt and os.path.isfile(outfile):
                meta = basic_meta[url]
                try:
                    handle = self.tivo_open(details_urls[url])
                    meta.update(metadata.from_details(handle.read()))
                    handle.close()
                except:
                    pass
                metafile = open(outfile + '.txt', 'w')
                metadata.dump(metafile, meta)
                metafile.close()

            status[url]['best_file'] = outfile
            status[url]['best_error_count'] = status[url]['ts_error_count']

            if retry_download:
                status[url]['rate'] = 0
                status[url]['size'] = 0
                status[url]['queued'] = True
                status[url]['retry'] += 1