Example #1
0
    def deleteLocalEpgidPath(self, epgid=False, file=False):

        if epgid:
            path = self.__getLocalEpgidPath(epgid, mkdir=False)
            json_file = self.__getEpgidJsonFile(epgid)
        elif file:
            path = file
            json_file = path + '.json.v1'
        else:
            return False

        if not vfs.exists(json_file):
            xbmc.log('could not delete %s, no info file found' % path)
            return False

        else:
            try:
                if file:
                    if vfs.exists(path):
                        vfs.delete(path)
                    if vfs.exists(json_file):
                        vfs.delete(json_file)
                elif epgid and vfs.exists(path):
                    for file_name in vfs.listdir(path)[1]:
                        file_path = vfs.path.join(path, file_name)
                        vfs.delete(file_path)
                    vfs.rmdir(path)
            except Exception, e:
                xbmc.log("failed to delete %s (%s)" % (path, str(e)))
            else:
Example #2
0
    def deleteLocalEpgidPath(self, epgid=False, file=False):

        if epgid:
            path = self.__getLocalEpgidPath(epgid, mkdir=False)
            json_file = self.__getEpgidJsonFile(epgid)
        elif file:
            path = file
            json_file = path + '.json.v1'
        else:
            return False

        if not vfs.exists(json_file):
            xbmc.log('could not delete %s, no info file found' % path)
            return False

        else:
            try:
                if file:
                    if vfs.exists(path):
                        vfs.delete(path)
                    if vfs.exists(json_file):
                        vfs.delete(json_file)
                elif epgid and vfs.exists(path):
                    for file_name in vfs.listdir(path)[1]:
                        file_path = vfs.path.join(path, file_name)
                        vfs.delete(file_path)
                    vfs.rmdir(path)
            except Exception, e:
                xbmc.log("failed to delete %s (%s)" % (path, str(e)))
            else:
Example #3
0
    def getImageUrl(self, epgid, filename):
        """
        liefert dynamisch die thumbnail url zurueck
        """
        url_local = vfs.path.join(self.__getLocalEpgidPath(epgid), filename)
        if vfs.exists(url_local):
            return url_local
        else:

            date_match = re.match('.*_(\d\d\.\d\d\.\d\d)_.*', filename)
            if date_match:
                date_part = "%s/" % date_match.group(1)
            else:
                date_part = ""

            url_online = 'http://thumbs.onlinetvrecorder.com/' + date_part + filename
            print url_online
            try:
                __sx__.Downloader(url_online,
                                  url_local,
                                  progress=False,
                                  background=True)
                xbmc.log('wrote pic %s' % url_local)
                return url_local
            except Exception, e:
                xbmc.log('%s: %s' % (url_local, str(e)))
                return url_online
Example #4
0
    def _play(self, otr, url=False):
        if not url:
            url = call.params['url']

        if not vfs.exists(url) and url.startswith('http'):
            url = self._downloadqueue(otr, url)

        if url:
            print "playing url %s" % url
            xbmc.Player().play(url)
            print "player returned"
        return True
Example #5
0
    def _play(self, otr, url=False):
        if not url:
            url = call.params['url']

        if not vfs.exists(url) and url.startswith('http'):
            url = self._downloadqueue(otr, url)

        if url:
            print "playing url %s" % url
            xbmc.Player().play(url)
            print "player returned"
        return True
Example #6
0
 def __findAllRecordingInfo(self):
     for dir_name in vfs.listdir(self.path)[0]:
         json_file = self.__getEpgidJsonFile(dir_name)
         try:
             if vfs.exists(json_file):
                 if not isinstance(json.loads( __sx__.noNull(vfs.File(json_file).read()) ), dict):
                     continue
             else:
                 continue
         except Exception, e:
             xbmc.log("%s: %s" % (json_file, str(e)))
         else:
             epgid = dir_name
             yield epgid
Example #7
0
            def download(request):
                response = urllib2.urlopen(request)
                self.size = self.chunk_read(response)

                if progress:
                    self.progress = xbmcgui.DialogProgress()
                    self.progress.create("Move", self.destination_file_name)

                xbmc.log("move %s -> %s" % (self.temp_file_path, self.destination_file_path))
                vfs.rename(self.temp_file_path, self.destination_file_path)
                if vfs.exists(self.temp_file_path):
                    vfs.copy(self.temp_file_path, self.destination_file_path)
                    vfs.delete(self.temp_file_path)

                self.progress.close()
Example #8
0
 def __findAllRecordingInfo(self):
     for dir_name in vfs.listdir(self.path)[0]:
         json_file = self.__getEpgidJsonFile(dir_name)
         try:
             if vfs.exists(json_file):
                 if not isinstance(
                         json.loads(
                             __sx__.noNull(vfs.File(json_file).read())),
                         dict):
                     continue
             else:
                 continue
         except Exception, e:
             xbmc.log("%s: %s" % (json_file, str(e)))
         else:
             epgid = dir_name
             yield epgid
Example #9
0
    def __init__(self):

        self.recordings = dict()

        # set path
        if __addon__.getSetting('otrDownloadFolder') in ['special://temp', '']:
            self.path = vfs.path.join(xbmc.translatePath('special://temp'), __addon__.getAddonInfo('id'))
        else:
            self.path = __addon__.getSetting('otrDownloadFolder')

        try:
            if not vfs.exists(self.path):
                vfs.mkdir(self.path)
                print "created dir %s" % self.path
        except OSError,e :
            __sx__.Notification(self.path, 'could not create dir (%s)' % str(e.strerror))
            sys.exit(0)
Example #10
0
    def __init__(self):

        self.recordings = dict()

        # set path
        if __addon__.getSetting('otrDownloadFolder') in ['special://temp', '']:
            self.path = vfs.path.join(xbmc.translatePath('special://temp'),
                                      __addon__.getAddonInfo('id'))
        else:
            self.path = __addon__.getSetting('otrDownloadFolder')

        try:
            if not vfs.exists(self.path):
                vfs.mkdir(self.path)
                print "created dir %s" % self.path
        except OSError, e:
            __sx__.Notification(self.path,
                                'could not create dir (%s)' % str(e.strerror))
            sys.exit(0)
Example #11
0
    def __findEpgidLocalCopies(self, local_path):
        for file_name in vfs.listdir(local_path)[1]:
            if file_name.endswith('.json.v1'):
                json_file = vfs.path.join(local_path, file_name)
                reference_file = json_file.rstrip('.json.v1')

                if not vfs.exists(reference_file):
                    continue

                try:
                    file_info = json.loads( __sx__.noNull(vfs.File(json_file).read()) )
                except Exception, e:
                    xbmc.log("%s: %s" % (json_file, str(e)))
                else:
                    if 'type' in file_info and file_info['type'] == 'local_copy':
                        file_info['file'] = reference_file
                        file_info['file_type'] = reference_file.split('.').pop()
                        file_info['json_file'] = json_file
                        yield {file_info['file_name']:file_info}
Example #12
0
    def __findEpgidLocalCopies(self, local_path):
        for file_name in vfs.listdir(local_path)[1]:
            if file_name.endswith('.json.v1'):
                json_file = vfs.path.join(local_path, file_name)
                reference_file = json_file.rstrip('.json.v1')

                if not vfs.exists(reference_file):
                    continue

                try:
                    file_info = json.loads(
                        __sx__.noNull(vfs.File(json_file).read()))
                except Exception, e:
                    xbmc.log("%s: %s" % (json_file, str(e)))
                else:
                    if 'type' in file_info and file_info[
                            'type'] == 'local_copy':
                        file_info['file'] = reference_file
                        file_info['file_type'] = reference_file.split(
                            '.').pop()
                        file_info['json_file'] = json_file
                        yield {file_info['file_name']: file_info}
Example #13
0
    def getImageUrl(self, epgid, filename):
        """
        liefert dynamisch die thumbnail url zurueck
        """
        url_local = vfs.path.join(self.__getLocalEpgidPath(epgid), filename)
        if vfs.exists(url_local):
            return url_local
        else:

            date_match = re.match('.*_(\d\d\.\d\d\.\d\d)_.*', filename)
            if date_match:
                date_part = "%s/" % date_match.group(1)
            else:
                date_part = ""

            url_online = 'http://thumbs.onlinetvrecorder.com/' + date_part + filename
            print url_online
            try:
                __sx__.Downloader(url_online, url_local, progress=False, background=True)
                xbmc.log('wrote pic %s' % url_local)
                return url_local
            except Exception, e:
                xbmc.log('%s: %s' % (url_local, str(e)))
                return url_online
Example #14
0
 def __getLocalEpgidPath(self, epgid, mkdir=True):
     path = vfs.path.join(self.path, epgid)
     if not vfs.exists(path) and mkdir:
         vfs.mkdir(path)
         print "created dir %s" % path
     return path
Example #15
0
 def __getLocalEpgidPath(self, epgid, mkdir=True):
     path = vfs.path.join(self.path, epgid)
     if not vfs.exists(path) and mkdir:
         vfs.mkdir(path)
         print "created dir %s" % path
     return path