def FindLogo(self, chtype, chname, mpath):
     self.logDebug("FindLogo")
     found = False
     setImage = ''
     LogoName = (chname[0:18] + '.png')
     LogoFolder = os.path.join(LOGO_LOC,LogoName)
     self.logoParser = lsHTMLParser()
     
     if FileAccess.exists(LogoFolder):
         return LogoFolder
     else:
         # if chtype == 1:
             # setImage = self.logoParser.retrieve_icon(chname)
         if chtype == 6 or chtype == 7:
             smpath = mpath.rsplit('/',2)[0] #Path Above mpath ie Series folder
             artSeries = xbmc.translatePath(os.path.join(smpath, 'logo.png'))
             artSeason = xbmc.translatePath(os.path.join(mpath, 'logo.png'))
             if FileAccess.exists(artSeries): 
                 setImage = artSeries
             elif FileAccess.exists(artSeason): 
                 setImage = artSeason
             # else:
                 # if REAL_SETTINGS.getSetting('EnhancedGuideData') == 'true': 
                     # self.Fanart_Download('tvshow', 'logo', id, LogoFolder)
                 
     if setImage.startswith('http'):
         requestDownload(setImage, LogoFolder)
     else:
         FileAccess.copy(setImage, LogoFolder)
     return LogoFolder
Exemplo n.º 2
0
def getSize(file):
    if FileAccess.exists(file):
        fileobject = FileAccess.open(file, "r")
        fileobject.seek(0,2) # move the cursor to the end of the file
        size = fileobject.tell()
        fileobject.close()
        return size
Exemplo n.º 3
0
    def SetDefaultArt_NEW(self, chname, mpath, arttypeEXT):
        self.logDebug('SetDefaultArt_NEW, chname = ' + chname +
                      ', arttypeEXT = ' + arttypeEXT)
        setImage = ''
        arttype = arttypeEXT.split(".")[0]
        MediaImage = os.path.join(MEDIA_LOC, (arttype + '.png'))
        StockImage = os.path.join(IMAGES_LOC, (arttype + '.png'))
        ChannelLogo = os.path.join(LOGO_LOC, chname[0:18] + '.png')

        if FileAccess.exists(ChannelLogo):
            self.logDebug('SetDefaultArt, Channel Logo')
            return ChannelLogo
        elif mpath[0:6] == 'plugin':
            self.logDebug('SetDefaultArt, Plugin Icon')
            icon = 'special://home/addons/' + (mpath.replace('plugin://',
                                                             '')) + '/icon.png'
            return icon
        elif FileAccess.exists(MediaImage):
            self.logDebug('SetDefaultArt, Media Image')
            return MediaImage
        elif FileAccess.exists(StockImage):
            self.logDebug('SetDefaultArt, Stock Image')
            return StockImage
        else:
            self.logDebug('SetDefaultArt, THUMB')
            return THUMB
Exemplo n.º 4
0
    def loadSettings(self):
        self.log("Loading settings from " + self.logfile)
        del self.currentSettings[:]
        try:
            if FileAccess.exists(self.logfile):
                try:
                    fle = FileAccess.open(self.logfile, "r")
                    curset = fle.readlines()
                    fle.close()
                except Exception, e:
                    self.log("Exception when reading settings: ")
                    self.log(traceback.format_exc(), xbmc.LOGERROR)

                for line in curset:
                    name = re.search('setting id="(.*?)"', line)

                    if name:
                        val = re.search(' value="(.*?)"', line)

                        if val:
                            self.currentSettings.append(
                                [name.group(1), val.group(1)])
        except Exception, e:
            print str(e)
            return
Exemplo n.º 5
0
    def setChannelBug(self):
        posx = self.channelBugPosition[0]
        posy = self.channelBugPosition[1]
        if self.showChannelBug:
            try:
                if not FileAccess.exists(self.channelLogos + ascii(
                        self.channels[self.currentChannel - 1].name) + '.png'):
                    self.getControl(103).setImage(IMAGES_LOC + 'Default2.png')
                    self.getControl(103).setPosition(posx, posy)
                original = Image.open(self.channelLogos +
                                      ascii(self.channels[self.currentChannel -
                                                          1].name) + '.png')
                converted_img = original.convert('LA')
                img_bright = ImageEnhance.Brightness(converted_img)
                converted_img = img_bright.enhance(2.0)
                if not FileAccess.exists(CHANNELBUG_LOC + ascii(self.channels[
                        self.currentChannel - 1].name) + '.png'):
                    converted_img.save(
                        CHANNELBUG_LOC +
                        ascii(self.channels[self.currentChannel - 1].name) +
                        '.png')
                self.getControl(103).setImage(
                    CHANNELBUG_LOC +
                    ascii(self.channels[self.currentChannel - 1].name) +
                    '.png')
                self.getControl(103).setPosition(posx, posy)

            except:
                self.getControl(103).setImage(IMAGES_LOC + 'Default2.png')
                self.getControl(103).setPosition(posx, posy)
        else:
            self.getControl(103).setImage('')
Exemplo n.º 6
0
    def getVideoLength(self, filename):
        self.log("getVideoLength, " + filename)
        if len(filename) == 0:
            self.log("getVideoLength, No file name specified")
            return 0

        if FileAccess.exists(filename) == False:
            if filename[0:6].lower() == 'smb://':
                self.log(
                    "getVideoLength, Unknown SMB file found, Trying to mount drive"
                )
                filename = FileAccess._openSMB(filename)
            else:
                self.log("getVideoLength, Unable to find the file")
                return 0

        base, ext = os.path.splitext(filename)
        ext = ext.lower()

        if ext in self.AVIExts:
            self.parser = AVIParser.AVIParser()
        elif ext in self.MP4Exts:
            self.parser = MP4Parser.MP4Parser()
        elif ext in self.MKVExts:
            self.parser = MKVParser.MKVParser()
        elif ext in self.FLVExts:
            self.parser = FLVParser.FLVParser()
        elif ext in self.TSExts:
            self.parser = TSParser.TSParser()
        elif ext in self.STRMExts:
            self.parser = STRMParser.STRMParser()
        else:
            self.log("getVideoLength, No parser found for extension " + ext)
            return 0
        return self.parser.determineLength(filename)
Exemplo n.º 7
0
    def SetDefaultArt(self, chname, mpath, arttypeEXT):
        self.log('SetDefaultArt')
        try:
            setImage = ''
            arttype = arttypeEXT.split(".")[0]
            MediaImage = os.path.join(MEDIA_LOC, (arttype + '.png'))
            StockImage = os.path.join(IMAGES_LOC, (arttype + '.png'))
            ChannelLogo = os.path.join(LOGO_LOC, chname[0:18] + '.png')

            # Channel Logo
            if FileAccess.exists(ChannelLogo) == True:
                return ChannelLogo
            # Plugin Icon
            elif mpath[0:6] == 'plugin':
                icon = 'special://home/addons/' + (mpath.replace(
                    'plugin://', '')) + '/icon.png'
                return icon
            # Selected Skin Fallback ie (poster.jpg, landscape.jpg, logo.png, etc...)
            elif FileAccess.exists(MediaImage) == True:
                return MediaImage
            # Default Skin Fallback ie (poster.jpg, landscape.jpg, logo.png, etc...)
            elif FileAccess.exists(StockImage) == True:
                return StockImage
            # PTVL Icon
            else:
                return THUMB
        except Exception, e:
            self.log(
                "script.pseudotv.live-Artdownloader: SetDefaultArt Failed" +
                str(e), xbmc.LOGERROR)
            return THUMB
Exemplo n.º 8
0
    def onAction(self, act):
        action = act.getId()

        if action in ACTION_PREVIOUS_MENU:
            if self.showingList == False:
                self.cancelChan()
                self.hideChanDetails()
            else:
                if self.madeChanges == 1:
                    dlg = xbmcgui.Dialog()

                    if dlg.yesno(xbmc.getLocalizedString(190), LANGUAGE(30032)):
                        ADDON_SETTINGS.writeSettings()
            
                        if CHANNEL_SHARING:
                            realloc = ADDON.getSetting('SettingsFolder')
                            FileAccess.copy(SETTINGS_LOC + '/settings2.xml', realloc + '/settings2.xml')

                self.close()
        elif act.getButtonCode() == 61575:      # Delete button
            curchan = self.listcontrol.getSelectedPosition() + 1

            if( (self.showingList == True) and (ADDON_SETTINGS.getSetting("Channel_" + str(curchan) + "_type") != "9999") ):
                dlg = xbmcgui.Dialog()

                if dlg.yesno(xbmc.getLocalizedString(190), LANGUAGE(30033)):
                    ADDON_SETTINGS.setSetting("Channel_" + str(curchan) + "_type", "9999")
                    self.updateListing(curchan)
                    self.madeChanges = 1
Exemplo n.º 9
0
    def onAction(self, act):
        action = act.getId()

        if action in ACTION_PREVIOUS_MENU:
            if self.showingList == False:
                self.cancelChan()
                self.hideChanDetails()
            else:
                if self.madeChanges == 1:
                    dlg = xbmcgui.Dialog()

                    if dlg.yesno(xbmc.getLocalizedString(190),
                                 LANGUAGE(30032)):
                        ADDON_SETTINGS.writeSettings()

                        if CHANNEL_SHARING:
                            realloc = ADDON.getSetting('SettingsFolder')
                            FileAccess.copy(SETTINGS_LOC + '/settings2.xml',
                                            realloc + '/settings2.xml')

                self.close()
        elif act.getButtonCode() == 61575:  # Delete button
            curchan = self.listcontrol.getSelectedPosition() + 1

            if ((self.showingList == True) and
                (ADDON_SETTINGS.getSetting("Channel_" + str(curchan) + "_type")
                 != "9999")):
                dlg = xbmcgui.Dialog()

                if dlg.yesno(xbmc.getLocalizedString(190), LANGUAGE(30033)):
                    ADDON_SETTINGS.setSetting(
                        "Channel_" + str(curchan) + "_type", "9999")
                    self.updateListing(curchan)
                    self.madeChanges = 1
Exemplo n.º 10
0
    def generate_snippet(self, doc, query):
        fa = FileAccess()
        stop_words = fa.get_stop_words()
        query = query.split()
        stopped_content = query
        final_query = " ".join(stopped_content)

        fq_list = final_query.split()
        doc_list = doc.split()
        intr = list(set(doc_list).intersection(fq_list))

        positions = []
        for each in intr:
            if each in intr:
                key = doc_list.index(each)
                positions.append(key)
            else:
                continue
        final_doc = ''
        i = 0
        for each in doc_list:
            if i in positions:
                q = '"' + each + '" '
                final_doc += q
            else:
                final_doc += each + ' '
            i += 1

        return final_doc
Exemplo n.º 11
0
    def FindArtwork(self, type, chtype, chname, id, dbid, mpath, arttypeEXT):
        self.log("FindArtwork, type = " + type + ' :chtype = ' + str(chtype) + ' :chname = ' + chname + ' :id = ' + str(id) + ' :dbid = ' + str(dbid) + ' :mpath = ' + mpath + ' :arttypeEXT = ' + arttypeEXT)
        setImage = ''
        CacheArt = False
        DefaultArt = False
        arttype = arttypeEXT.split(".")[0]
        arttypeEXT_fallback = arttypeEXT.replace('landscape','fanart').replace('clearart','logo').replace('character','logo').replace('folder','poster')
        arttype_fallback = arttypeEXT_fallback.split(".")[0]
        
        if int(chtype) <= 7:
            self.logDebug('FindArtwork, Infolder Artwork')
            smpath = mpath.rsplit('/',2)[0] #Path Above mpath ie Series folder
            artSeries = xbmc.translatePath(os.path.join(smpath, arttypeEXT))
            artSeason = xbmc.translatePath(os.path.join(mpath, arttypeEXT))
            artSeries_fallback = xbmc.translatePath(os.path.join(smpath, arttypeEXT_fallback))
            artSeason_fallback = xbmc.translatePath(os.path.join(mpath, arttypeEXT_fallback))

            if FileAccess.exists(artSeries): 
                return artSeries
            elif FileAccess.exists(artSeason):
                return artSeason
            elif FileAccess.exists(artSeries_fallback): 
                return artSeries_fallback
            elif FileAccess.exists(artSeason_fallback):
                return artSeason_fallback
        else:
            return self.SetDefaultArt(chname, mpath, arttypeEXT)
Exemplo n.º 12
0
def getSize(file):
    if FileAccess.exists(file):
        fileobject = FileAccess.open(file, "r")
        fileobject.seek(0, 2)  # move the cursor to the end of the file
        size = fileobject.tell()
        fileobject.close()
        return size
Exemplo n.º 13
0
    def SetDefaultArt(self, chname, mpath, arttypeEXT):
        self.logDebug('SetDefaultArt, chname = ' + chname + ', arttypeEXT = ' +
                      arttypeEXT)
        try:
            setImage = ''
            arttype = arttypeEXT.split(".")[0]
            MediaImage = os.path.join(MEDIA_LOC, (arttype + '.png'))
            StockImage = os.path.join(IMAGES_LOC, (arttype + '.png'))
            ChannelLogo = os.path.join(LOGO_LOC, chname[0:18] + '.png')

            if FileAccess.exists(ChannelLogo):
                self.logDebug('SetDefaultArt, Channel Logo')
                return ChannelLogo
            elif mpath[0:6] == 'plugin':
                self.logDebug('SetDefaultArt, Plugin Icon')
                icon = 'special://home/addons/' + (mpath.replace(
                    'plugin://', '')) + '/icon.png'
                return icon
            elif FileAccess.exists(MediaImage):
                self.logDebug('SetDefaultArt, Media Image')
                return MediaImage
            elif FileAccess.exists(StockImage):
                self.logDebug('SetDefaultArt, Stock Image')
                return StockImage
            else:
                self.logDebug('SetDefaultArt, THUMB')
                return THUMB
        except Exception, e:
            self.log(
                "script.pseudotv.live-Artdownloader: SetDefaultArt Failed" +
                str(e), xbmc.LOGERROR)
            buggalo.onExceptionRaised()
Exemplo n.º 14
0
    def FindLogo(self, chtype, chname, mpath):
        self.logDebug("FindLogo")
        found = False
        setImage = ''
        LogoName = (chname[0:18] + '.png')
        LogoFolder = os.path.join(LOGO_LOC, LogoName)
        self.logoParser = lsHTMLParser()

        if FileAccess.exists(LogoFolder):
            return LogoFolder
        else:
            # if chtype == 1:
            # setImage = self.logoParser.retrieve_icon(chname)
            if chtype == 6 or chtype == 7:
                smpath = mpath.rsplit('/',
                                      2)[0]  #Path Above mpath ie Series folder
                artSeries = xbmc.translatePath(os.path.join(
                    smpath, 'logo.png'))
                artSeason = xbmc.translatePath(os.path.join(mpath, 'logo.png'))
                if FileAccess.exists(artSeries):
                    setImage = artSeries
                elif FileAccess.exists(artSeason):
                    setImage = artSeason
                # else:
                # if REAL_SETTINGS.getSetting('EnhancedGuideData') == 'true':
                # self.Fanart_Download('tvshow', 'logo', id, LogoFolder)

        if setImage.startswith('http'):
            requestDownload(setImage, LogoFolder)
        else:
            FileAccess.copy(setImage, LogoFolder)
        return LogoFolder
Exemplo n.º 15
0
    def FindBug(self, chtype, chname, mediapath):
        self.log("FindBug")
        setImage = ''
        BugName = (chname[0:18] + '.png')
        BugCache = os.path.join(LOGO_CACHE_LOC, BugName)
        BugFolder = os.path.join(LOGO_LOC, BugName)
        BugDefault = os.path.join(IMAGES_LOC, 'Default.png')
        BugDefault_YT = os.path.join(IMAGES_LOC, 'Youtube.png')

        if REAL_SETTINGS.getSetting('UNAlter_ChanBug') == 'false':
            if FileAccess.exists(BugCache):
                print('Find Local Cache Bug')
                setImage = BugCache
            elif FileAccess.exists(BugFolder):
                print('Find Local Logo Bug')
                BugCache = self.ConvertBug(BugFolder, BugCache)
                setImage = BugCache
            else:
                setImage = BugDefault
        else:
            if FileAccess.exists(BugFolder):
                setImage = BugFolder
            else:
                setImage = BugDefault
        self.log("FindBug, setImage = " + setImage)
        return setImage
Exemplo n.º 16
0
    def FindBug(self, chtype, chname):
        self.log("FindBug, chname = " + chname)
        try:
            FindBug_Type = int(REAL_SETTINGS.getSetting('Enable_ChannelBug'))
            
            OEMBugFLE_ANI = xbmc.translatePath(os.path.join(LOGO_LOC,(chname + '.gif')))
            OEMBugFLE = xbmc.translatePath(os.path.join(LOGO_LOC,(chname + '.png')))
            NEWBugFLE = xbmc.translatePath(os.path.join(LOGO_LOC,(chname + '_mono.png')))

            OEMDefaultBugFLE = os.path.join(IMAGES_LOC,'logo.png')
            NEWDefaultBugFLE = os.path.join(IMAGES_LOC,'icon_mono.png')
                                
            # no channel bug for livetv/internettv
            if chtype in [8,9]:
                return 'NA.png' 

            if FindBug_Type > 0:
                if FindBug_Type == 3:
                    if FileAccess.exists(OEMBugFLE_ANI) == True:
                        return OEMBugFLE_ANI
                if FindBug_Type == 2:
                    if FileAccess.exists(NEWBugFLE) == True:
                        return NEWBugFLE
                    if FileAccess.exists(NEWBugFLE) == False and FileAccess.exists(OEMBugFLE) == True:
                        return self.ConvertBug(OEMBugFLE, NEWBugFLE)
                    return NEWDefaultBugFLE
                if FileAccess.exists(OEMBugFLE) == True:
                    return OEMBugFLE
                return OEMDefaultBugFLE
        except Exception,e:  
            self.log("FindBug, Failed" + str(e), xbmc.LOGERROR)
            return 'NA.png'
Exemplo n.º 17
0
 def FindBug(self, chtype, chname):
     self.log("FindBug, chname = " + chname)
     try:
         setImage = ''
         BugFLE = xbmc.translatePath(os.path.join(LOGO_LOC,(chname + '.png')))
         cachedthumb = xbmc.getCacheThumbName(BugFLE)
         cachefile = xbmc.translatePath(os.path.join(ART_LOC, cachedthumb[0], cachedthumb[:-4] + ".png")).replace("\\", "/")
         DefaultBug = self.getDefaultBug(chname)
         
         # no channel bug for livetv/internettv
         if chtype in [8,9]:
             return 'NA.png' 
         else:
             if REAL_SETTINGS.getSetting('UNAlter_ChanBug') == 'true':
                 if FileAccess.exists(BugFLE) == False:
                     BugFLE = DefaultBug
                 return BugFLE
             else:
                 if FileAccess.exists(cachefile) == True:
                     return cachefile
                 elif FileAccess.exists(BugFLE) == False:
                     return DefaultBug
                 return self.ConvertBug(BugFLE, cachefile)
     except Exception,e:  
         self.log("FindBug, Failed" + str(e), xbmc.LOGERROR)
         return 'NA.png'
Exemplo n.º 18
0
def phase2(model):
    stop = Stopper()
    stopped_corpus = stop.build_stopped_inverted_index()
    stop_inv_index = stopped_corpus[0]
    stop_total_corpus = stopped_corpus[1]
    task3a_folder = os.path.join(os.getcwd(), 'task3a')
    file_name = "task3a_cosine_stopped.txt"
    r = Retriever()
    fa = FileAccess()
    relevance_data = fa.get_relevance_data()
    query_dict = fa.read_queries()
    result_file = task3a_folder + '/' + file_name
    stopped_queries = stop.get_stopped_queries(query_dict)
    qe = QueryExpander(query_dict=stopped_queries,
                       filename=result_file,
                       clean=False)
    expanded_stopped_queries = qe.get_expanded_queries()
    r.run_all_queries(inverted_index=stop_inv_index,
                      total_corpus=stop_total_corpus,
                      relevance_data=relevance_data,
                      query_dict=expanded_stopped_queries,
                      model=model,
                      task_id="phase2",
                      notes="stopped_expanded",
                      store_queries='stopped_expanded')
Exemplo n.º 19
0
    def FindBug(self, chtype, chname, mediapath):
        print 'FindBug' 
        print chtype, chname, mediapath
        setImage = ''
        BugName = (chname + '.png')
        BugCache = os.path.join(LOGO_CACHE_LOC,BugName)
        BugFolder = os.path.join(LOGO_LOC,BugName)
        BugDefault = os.path.join(IMAGES_LOC,'Default.png')
        BugDefault_YT = os.path.join(IMAGES_LOC,'Youtube.png')

        if REAL_SETTINGS.getSetting('UNAlter_ChanBug') == 'false':
            
            if FileAccess.exists(BugCache):
                print ('Find Local Cache Bug')
                setImage = BugCache
                               
            elif FileAccess.exists(BugFolder):
                print ('Find Local Logo Bug')
                BugCache = self.ConvertBug(BugFolder, BugCache)
                setImage = BugCache
            else:
                setImage = BugDefault
        else:
            if FileAccess.exists(BugFolder):
                setImage = BugFolder
            else:
                setImage = BugDefault

        print 'FindBug return', setImage
        return setImage
Exemplo n.º 20
0
    def FindBug(self, chtype, chname):
        self.log("FindBug, chname = " + chname)
        try:
            setImage = ''
            BugFLE = xbmc.translatePath(
                os.path.join(LOGO_LOC, (chname + '.png')))
            cachedthumb = xbmc.getCacheThumbName(BugFLE)
            cachefile = xbmc.translatePath(
                os.path.join(ART_LOC, cachedthumb[0],
                             cachedthumb[:-4] + ".png")).replace("\\", "/")
            DefaultBug = self.getDefaultBug(chname)

            # no channel bug for livetv/internettv
            if chtype in [8, 9]:
                return 'NA.png'
            else:
                if REAL_SETTINGS.getSetting('UNAlter_ChanBug') == 'true':
                    if FileAccess.exists(BugFLE) == False:
                        BugFLE = DefaultBug
                    return BugFLE
                else:
                    if FileAccess.exists(cachefile) == True:
                        return cachefile
                    elif FileAccess.exists(BugFLE) == False:
                        return DefaultBug
                    return self.ConvertBug(BugFLE, cachefile)
        except Exception, e:
            self.log("FindBug, Failed" + str(e), xbmc.LOGERROR)
            return 'NA.png'
Exemplo n.º 21
0
 def SetDefaultArt(self, chname, mpath, arttypeEXT):
     self.log('SetDefaultArt')
     try:
         setImage = ''
         arttype = arttypeEXT.split(".")[0]
         MediaImage = os.path.join(MEDIA_LOC, (arttype + '.png'))
         StockImage = os.path.join(IMAGES_LOC, (arttype + '.png'))
         ChannelLogo = os.path.join(LOGO_LOC,chname + '.png')
         
         # Selected Skin Fallback ie (poster.jpg, landscape.jpg, logo.png, etc...)
         if FileAccess.exists(MediaImage) == True:
             self.log('SetDefaultArt, return MediaImage')
             return MediaImage
         # Channel Logo
         elif FileAccess.exists(ChannelLogo) == True:
             self.log('SetDefaultArt, return ChannelLogo')
             return ChannelLogo
         # Plugin Icon
         elif mpath[0:6] == 'plugin':
             icon = 'special://home/addons/'+(mpath.replace('plugin://',''))+ '/icon.png'
             self.log('SetDefaultArt, return plugin icon')
             return icon
         # Default Skin Fallback ie (poster.jpg, landscape.jpg, logo.png, etc...)
         elif FileAccess.exists(StockImage) == True:
             self.log('SetDefaultArt, return StockImage')
             return StockImage
         # PTVL Icon
         else:
             self.log('SetDefaultArt, return THUMB')
             return THUMB
     except Exception,e:  
         self.log("script.pseudotv.live-Artdownloader: SetDefaultArt Failed" + str(e), xbmc.LOGERROR)
         return THUMB
Exemplo n.º 22
0
 def SetDefaultArt(self, chname, mpath, arttypeEXT):
     self.log('SetDefaultArt, chname = ' + chname + ', arttypeEXT = ' + arttypeEXT)
     try:
         setImage = ''
         arttype = arttypeEXT.split(".")[0]
         MediaImage = os.path.join(MEDIA_LOC, (arttype + '.png'))
         StockImage = os.path.join(IMAGES_LOC, (arttype + '.png'))
         ChannelLogo = os.path.join(LOGO_LOC,chname[0:18] + '.png')
         
         if FileAccess.exists(ChannelLogo):
             self.log('SetDefaultArt, Channel Logo')
             return ChannelLogo
         elif mpath[0:6] == 'plugin':
             self.log('SetDefaultArt, Plugin Icon')
             icon = 'special://home/addons/'+(mpath.replace('plugin://',''))+ '/icon.png'
             return icon
         elif FileAccess.exists(MediaImage):
             self.log('SetDefaultArt, Media Image')
             return MediaImage
         elif FileAccess.exists(StockImage):
             self.log('SetDefaultArt, Stock Image')
             return StockImage
         else:
             self.log('SetDefaultArt, THUMB')
             return THUMB
     except Exception,e:  
         self.log("script.pseudotv.live-Artdownloader: SetDefaultArt Failed" + str(e), xbmc.LOGERROR)
         self.log(traceback.format_exc(), xbmc.LOGERROR)
Exemplo n.º 23
0
    def build_stopped_corpus(self):
        cwd = os.getcwd()
        clean_cacm = os.path.join(cwd, 'clean_cacm')
        stopped_cacm = os.path.join(cwd, 'stopped_cacm')
        fa = FileAccess()

        if not os.path.exists(clean_cacm):
            print "Clean corpus doesn't exist. It is created now. " \
                  "PLease put cleaned files inside the corpus folder"
            os.makedirs(clean_cacm, 0755)
            return
        if not os.path.exists(stopped_cacm):
            os.makedirs(stopped_cacm, 0755)

        stop_words = fa.get_stop_words()
        os.chdir(clean_cacm)

        for eachfile in glob.glob('*.html'):
            print eachfile
            content = open(eachfile).read()
            content = content.split()
            stopped_content = [x for x in content if x not in stop_words]
            final_content = " ".join(stopped_content)

            clean_file = open(os.path.join(stopped_cacm, eachfile), 'w')
            clean_file.write(final_content)
            clean_file.close()
Exemplo n.º 24
0
    def getVideoLength(self, filename):
        self.log("getVideoLength, " + filename)
        if len(filename) == 0:
            self.log("getVideoLength, No file name specified")
            return 0

        if FileAccess.exists(filename) == False:
            if filename[0:6].lower() == 'smb://':
                self.log("getVideoLength, Unknown SMB file found, Trying to mount drive")
                filename = FileAccess._openSMB(filename)
            else:
                self.log("getVideoLength, Unable to find the file")
                return 0

        base, ext = os.path.splitext(filename)
        ext = ext.lower()
        
        if ext in self.AVIExts:
            self.parser = AVIParser.AVIParser()
        elif ext in self.MP4Exts:
            self.parser = MP4Parser.MP4Parser()
        elif ext in self.MKVExts:
            self.parser = MKVParser.MKVParser()
        elif ext in self.FLVExts:
            self.parser = FLVParser.FLVParser()
        elif ext in self.TSExts:
            self.parser = TSParser.TSParser()
        elif ext in self.STRMExts:
            self.parser = STRMParser.STRMParser()
        else:
            self.log("getVideoLength, No parser found for extension " + ext)
            return 0
        return self.parser.determineLength(filename)
Exemplo n.º 25
0
    def loadSettings(self):
        self.log("Loading settings from " + self.logfile)

        if Globals.GlobalFileLock.lockFile(self.logfile) == False:
            self.log("Unable to lock the settings file before loading it")

        del self.currentSettings[:]

        if FileAccess.exists(self.logfile):
            try:
                fle = FileAccess.open(self.logfile, "r")
                curset = fle.readlines()
                fle.close()
            except:
                pass

            for line in curset:
                name = re.search('setting id="(.*?)"', line)

                if name:
                    val = re.search(' value="(.*?)"', line)

                    if val:
                        self.currentSettings.append(
                            [name.group(1), val.group(1)])

        Globals.GlobalFileLock.unlockFile(self.logfile)
Exemplo n.º 26
0
    def buildMixedFileList(self, dom1, channel):
        fileList = []
        self.log('buildMixedFileList')

        try:
            rules = dom1.getElementsByTagName('rule')
            order = dom1.getElementsByTagName('order')
        except:
            self.log('buildMixedFileList Problem parsing playlist ' + filename,
                     xbmc.LOGERROR)
            xml.close()
            return fileList

        for rule in rules:
            rulename = rule.childNodes[0].nodeValue

            if FileAccess.exists(
                    xbmc.translatePath('special://profile/playlists/video/') +
                    rulename):
                FileAccess.copy(
                    xbmc.translatePath('special://profile/playlists/video/') +
                    rulename, MADE_CHAN_LOC + rulename)
                fileList.extend(
                    self.buildFileList(MADE_CHAN_LOC + rulename, channel))
            else:
                fileList.extend(
                    self.buildFileList(GEN_CHAN_LOC + rulename, channel))

        self.log("buildMixedFileList returning")
        return fileList
Exemplo n.º 27
0
    def FindArtwork_NEW(self, type, chtype, chname, id, dbid, mpath, arttypeEXT):
        self.logDebug("FindArtwork_NEW, type = " + type + ', chtype = ' + str(chtype) + ', chname = ' + chname + ', id = ' + str(id) + ', dbid = ' + str(dbid) + ', arttypeEXT = ' + arttypeEXT)
        setImage = THUMB
        CacheArt = False
        DefaultArt = False
        arttype = arttypeEXT.split(".")[0]
        arttypeEXT_fallback = arttypeEXT.replace('landscape','fanart').replace('clearart','logo').replace('character','logo').replace('folder','poster')
        arttype_fallback = arttypeEXT_fallback.split(".")[0]
        
        if chtype <= 7:
            self.logDebug('FindArtwork_NEW, Infolder Artwork')
            smpath = mpath.rsplit('/',2)[0] #Path Above mpath ie Series folder
            artSeries = xbmc.translatePath(os.path.join(smpath, arttypeEXT))
            artSeason = xbmc.translatePath(os.path.join(mpath, arttypeEXT))
            artSeries_fallback = xbmc.translatePath(os.path.join(smpath, arttypeEXT_fallback))
            artSeason_fallback = xbmc.translatePath(os.path.join(mpath, arttypeEXT_fallback))

            if FileAccess.exists(artSeries): 
                return artSeries
            elif FileAccess.exists(artSeason):
                return artSeason
            elif FileAccess.exists(artSeries_fallback): 
                return artSeries_fallback
            elif FileAccess.exists(artSeason_fallback):
                return artSeason_fallback
            elif dbid != '0':
                return self.dbidArt(type, chname, mpath, dbid, arttypeEXT)
        else:
            if id == '0':
                if type == 'youtube':
                    self.logDebug('FindArtwork_NEW, Youtube')
                    return "http://i.ytimg.com/vi/"+dbid+"/mqdefault.jpg"
                    # return "http://img.youtube.com/vi/"+dbid+"/0.jpg"
                elif type == 'rss':
                    self.logDebug('FindArtwork_NEW, RSS')
                    if dbid != '0':
                        return dbid.decode('base64')
                    else:
                        return self.SetDefaultArt_NEW(chname, mpath, arttypeEXT)
                # elif mpath[0:4] == 'upnp':
                    # self.logDebug('FindArtwork_NEW, UPNP Thumb')
                    # return self.JsonThumb(chname, arttypeEXT, mediapath) 
                else:
                    return self.SetDefaultArt_NEW(chname, mpath, arttypeEXT)
            else:
                self.logDebug('FindArtwork_NEW, Artwork Cache')
                fle = id + '-' + arttypeEXT
                ext = arttypeEXT.split('.')[1]
                url = os.path.join(mpath, fle)
                cachedthumb = xbmc.getCacheThumbName(url)
                cachefile = xbmc.translatePath(os.path.join(ART_LOC, cachedthumb[0], cachedthumb[:-4] + "." + ext)).replace("\\", "/")
                
                if FileAccess.exists(cachefile) == True:
                    return cachefile
                else:
                    if REAL_SETTINGS.getSetting('EnhancedGuideData') == 'true': 
                        self.logDebug('FindArtwork_NEW, Artwork Download')
                        self.DownloadArt(type, id, arttype, arttype_fallback, cachefile)
                        return cachefile
Exemplo n.º 28
0
    def DownloadArt_Thread(self, data):
        self.log('DownloadArt_Thread')
        type = data[0]
        id = data[1]
        arttype = data[2]
        arttype_fallback = data[3]
        cachefile = data[4]
        print cachefile
        drive, Dpath = os.path.splitdrive(cachefile)
        path, filename = os.path.split(Dpath)
        print drive, Dpath, path, filename

        if not FileAccess.exists(os.path.join(drive,path)):
            FileAccess.makedirs(os.path.join(drive,path))   
                
        if type == 'tvshow':
            self.logDebug('DownloadArt_Thread, tvshow')
            FanTVDownload = True
            TVFilePath = cachefile
            tvdb_Types = ['banner', 'fanart', 'folder', 'poster']
                
            try:
                if arttype in tvdb_Types:
                    self.logDebug('DownloadArt_Thread, TVDB')
                    arttype = arttype.replace('banner', 'graphical').replace('folder', 'poster')
                    tvdb = str(self.tvdbAPI.getBannerByID(id, arttype))
                    tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace("'", "") 
                    if tvdbPath.startswith('http'):
                        requestDownload(tvdbPath,TVFilePath)
                        FanTVDownload = False
            except Exception,e:
                self.log('DownloadArt_Thread, self.tvdbAPI Failed!')
                pass
                
            if FanTVDownload == True:
                self.logDebug('DownloadArt_Thread, Fanart.TV')
                try:
                    arttype = arttype.replace('graphical', 'banner').replace('folder', 'poster').replace('fanart', 'landscape')
                    fan = str(self.fanarttv.get_image_list_TV(id))
                    file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(fan)
                    pref_language = self.fanarttv.get_abbrev(REAL_SETTINGS.getSetting('limit_preferred_language'))
                    
                    for f in file_detail:
                        languages = re.search("'language' *: *(.*?),", f)
                        art_types = re.search("'art_type' *: *(.*?),", f)
                        fanPaths = re.search("'url' *: *(.*?),", f)       
                        if languages and len(languages.group(1)) > 0:
                            language = (languages.group(1)).replace("u'",'').replace("'",'')
                            if language == pref_language:
                                if art_types and len(art_types.group(1)) > 0:
                                    art_type = art_types.group(1).replace("u'",'').replace("'",'').replace("[",'').replace("]",'')
                                    if art_type.lower() == arttype.lower():
                                        if fanPaths and len(fanPaths.group(1)) > 0:
                                            fanPath = fanPaths.group(1).replace("u'",'').replace("'",'')
                                            if fanPath.startswith('http'):
                                                requestDownload(fanPath,TVFilePath)
                                                break 
                except:
                    pass
Exemplo n.º 29
0
    def DownloadArt(self, type, id, fle, typeEXT, ART_LOC):
        print ('DownloadArt')
        tvdbAPI = TVDB(TVDB_API_KEY)
        tmdbAPI = TMDB(TMDB_API_KEY)     

        if not FileAccess.exists(ART_LOC):
            os.makedirs(ART_LOC)

        ArtType = typeEXT.split('.')[0]
        MediaImage = os.path.join(MEDIA_LOC, (ArtType + '.png'))
        DefaultImage = os.path.join(DEFAULT_MEDIA_LOC, (ArtType + '.png'))
        
        if FileAccess.exists(MediaImage):
            setImage = MediaImage
        elif FileAccess.exists(DefaultImage):
            setImage = DefaultImage
        else:
            setImage = ''
        
        if type == 'tvshow':
            FanTVDownload = False
            TVFilePath = os.path.join(ART_LOC, fle) 
            tvdb_Types = ['banner', 'fanart', 'folder', 'poster']
            
            if ArtType in tvdb_Types:
                ArtType = ArtType.replace('banner', 'graphical').replace('folder', 'poster')
                tvdb = str(tvdbAPI.getBannerByID(id, ArtType))
                try:
                    tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace("'", "") 
                    resource = urllib.urlopen(tvdbPath)
                    output = FileAccess.open(TVFilePath, 'w')
                    output.write(resource.read())
                    output.close()
                    return TVFilePath
                except Exception,e:
                    FanTVDownload = True
                    print ('tvdbAPI Failed!') 
                    pass
            else:
                FanTVDownload = True

            if FanTVDownload == True:
                ArtType = ArtType.replace('graphical', 'banner').replace('folder', 'poster').replace('fanart', 'tvfanart')
                fan = fanarttv.get_image_list_TV(id)
                try:
                    data = str(fan).replace("[", "").replace("]", "").replace("'", "")
                    data = data.split('}, {')
                    fanPath = str([s for s in data if ArtType in s]).split("', 'art_type: ")[0]
                    match = re.search("url *: *(.*?),", fanPath)
                    fanPath = match.group().replace(",", "").replace("url: u", "").replace("url: ", "")
                    resource = urllib.urlopen(fanPath)
                    output = FileAccess.open(TVFilePath, 'w')
                    output.write(resource.read())
                    output.close()
                    return TVFilePath
                except Exception,e:
                    print ('FanTVDownload Failed!')    
                    pass
Exemplo n.º 30
0
def Restore(bak, org):
    log('Restore ' + str(bak) + ' - ' + str(org))
    if FileAccess.exists(bak):
        if FileAccess.exists(org):
            try:
                xbmcvfs.delete(org)
            except:
                pass
        FileAccess.rename(bak, org)
    xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoTV Lite", "Restore Complete, Restarting...", 1000, THUMB) )
Exemplo n.º 31
0
    def showChannelLabel(self, channel):
        self.log('showChannelLabel ' + str(channel))

        if self.channelLabelTimer.isAlive():
            self.channelLabelTimer.cancel()
            self.channelLabelTimer = threading.Timer(5.0, self.hideChannelLabel)

        tmp = self.inputChannel
        self.hideChannelLabel()
        self.inputChannel = tmp
        curlabel = 0

        if channel > 99:
            self.channelLabel[curlabel].setImage(IMAGES_LOC + 'label_' + str(channel // 100) + '.png')
            self.channelLabel[curlabel].setVisible(True)
            curlabel += 1

        if channel > 9:
            self.channelLabel[curlabel].setImage(IMAGES_LOC + 'label_' + str((channel % 100) // 10) + '.png')
            self.channelLabel[curlabel].setVisible(True)
            curlabel += 1

        self.channelLabel[curlabel].setImage(IMAGES_LOC + 'label_' + str(channel % 10) + '.png')
        self.channelLabel[curlabel].setVisible(True)

        if self.inputChannel == -1 and self.infoOnChange == True:
            self.infoOffset = 0
            self.showInfo(5.0)

        if self.showChannelBug == True:
            try:
                if not FileAccess.exists(self.channelLogos + ascii(self.channels[self.currentChannel - 1].name) + '.png'):
                    self.getControl(103).setImage(IMAGES_LOC + 'Default2.png')
                original = Image.open(self.channelLogos + ascii(self.channels[self.currentChannel - 1].name) + '.png')               
                converted_img = original.convert('LA')
                if not FileAccess.exists(CHANNELBUG_LOC + ascii(self.channels[self.currentChannel - 1].name) + '.png'):
                    converted_img.save(CHANNELBUG_LOC + ascii(self.channels[self.currentChannel - 1].name) + '.png')
                self.getControl(103).setImage(CHANNELBUG_LOC + ascii(self.channels[self.currentChannel - 1].name) + '.png')
            except:
                pass
        else:
            try:
                self.getControl(103).setImage('')
            except:
                pass

        if xbmc.getCondVisibility('Player.ShowInfo'):
            json_query = '{"jsonrpc": "2.0", "method": "Input.Info", "id": 1}'
            self.ignoreInfoAction = True
            self.channelList.sendJSON(json_query);
            
        self.channelLabelTimer.name = "ChannelLabel"
        self.channelLabelTimer.start()
        self.startNotificationTimer(10.0)
        self.log('showChannelLabel return')
Exemplo n.º 32
0
    def showChannelLabel(self, channel):
        self.log('showChannelLabel ' + str(channel))

        if self.channelLabelTimer.isAlive():
            self.channelLabelTimer.cancel()
            self.channelLabelTimer = threading.Timer(3.0, self.hideChannelLabel)

        tmp = self.inputChannel
        self.hideChannelLabel()
        self.inputChannel = tmp
        curlabel = 0

        if channel > 99:
            self.channelLabel[curlabel].setImage(IMAGES_LOC + 'label_' + str(channel // 100) + '.png')
            self.channelLabel[curlabel].setVisible(True)
            curlabel += 1

        if channel > 9:
            self.channelLabel[curlabel].setImage(IMAGES_LOC + 'label_' + str((channel % 100) // 10) + '.png')
            self.channelLabel[curlabel].setVisible(True)
            curlabel += 1

        self.channelLabel[curlabel].setImage(IMAGES_LOC + 'label_' + str(channel % 10) + '.png')
        self.channelLabel[curlabel].setVisible(True)

        if self.inputChannel == -1 and self.infoOnChange == True:
            self.infoOffset = 0
            xbmc.sleep(self.channelDelay)
            self.showInfo(self.infoDuration)

        if self.showChannelBug == True:
            try:
                if not FileAccess.exists(self.channelLogos + ascii(self.channels[self.currentChannel - 1].name) + '.png'):
                    self.getControl(103).setImage(IMAGES_LOC + 'Default2.png')
                original = Image.open(self.channelLogos + ascii(self.channels[self.currentChannel - 1].name) + '.png')
                converted_img = original.convert('LA')
                img_bright = ImageEnhance.Brightness(converted_img)
                converted_img = img_bright.enhance(2.0)
                if not FileAccess.exists(CHANNELBUG_LOC + ascii(self.channels[self.currentChannel - 1].name) + '.png'):
                    converted_img.save(CHANNELBUG_LOC + ascii(self.channels[self.currentChannel - 1].name) + '.png')
                self.getControl(103).setImage(CHANNELBUG_LOC + ascii(self.channels[self.currentChannel - 1].name) + '.png')
            except:
                self.getControl(103).setImage(IMAGES_LOC + 'Default2.png')
        else:
            self.getControl(103).setImage('')

        if xbmc.getCondVisibility('Player.ShowInfo'):
            json_query = '{"jsonrpc": "2.0", "method": "Input.Info", "id": 1}'
            self.ignoreInfoAction = True
            self.channelList.sendJSON(json_query);
            
        self.channelLabelTimer.name = "ChannelLabel"
        self.channelLabelTimer.start()
        self.startNotificationTimer()
        self.log('showChannelLabel return')
Exemplo n.º 33
0
 def writeSettingsNew(self, updateDialog):
     self.log("writeSettingsNew")
     updateDialog.update(90, "Repairing Channel Configurations", "Saving Changes")
     if FileAccess.exists(Globals.SETTINGS_FLE_REPAIR):
         FileAccess.delete(Globals.SETTINGS_FLE_REPAIR)
         
     try:
         fle = FileAccess.open(Globals.SETTINGS_FLE_REPAIR, "w")
     except Exception,e:
         self.log("Unable to open the file for writing")
         return
Exemplo n.º 34
0
 def writeSettingsNew(self, updateDialog):
     self.log("writeSettingsNew")
     updateDialog.update(90, "Repairing Channel Configurations", "Saving Changes")
     if FileAccess.exists(self.repairfile):
         xbmcvfs.delete(self.repairfile)
         
     try:
         fle = FileAccess.open(self.repairfile, "w")
     except Exception,e:
         self.log("Unable to open the file for writing")
         return
Exemplo n.º 35
0
def evalaution():
    p_k = [5, 20]
    fa = FileAccess()
    relevance_data = fa.get_relevance_data()
    base_dir = os.getcwd()
    all_runs = os.path.join(os.getcwd(), 'all_runs')
    os.chdir(all_runs)
    e = Evaluation()

    for eachfile in glob.glob('*.txt'):
        e.evaluate(eachfile, p_k, base_dir, relevance_data)
Exemplo n.º 36
0
    def storeFiles(self):
        self.log('storeFiles')

        if CHANNEL_SHARING == False:
            return

        realloc = ADDON.getSetting('SettingsFolder')
        FileAccess.copy(SETTINGS_LOC + '/settings2.xml', realloc + '/settings2.xml')
        realloc = xbmc.translatePath(os.path.join(realloc, 'cache')) + '/'

        for i in range(self.maxChannels + 1):
            FileAccess.copy(CHANNELS_LOC + 'channel_' + str(i) + '.m3u', realloc + 'channel_' + str(i) + '.m3u')
Exemplo n.º 37
0
def Restore(bak, org):
    log("Restore " + str(bak) + " - " + str(org))
    if FileAccess.exists(bak):
        if FileAccess.exists(org):
            try:
                xbmcvfs.delete(org)
            except:
                pass
        FileAccess.rename(bak, org)
    xbmc.executebuiltin(
        "Notification( %s, %s, %d, %s)" % ("PseudoTV Lite", "Restore Complete, Restarting...", 1000, THUMB)
    )
Exemplo n.º 38
0
def Backup(org, bak):
    log("Backup " + str(org) + " - " + str(bak))
    if FileAccess.exists(org):
        if FileAccess.exists(bak):
            try:
                xbmcvfs.delete(bak)
            except:
                pass
        FileAccess.copy(org, bak)

    if DEBUG == "true":
        xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoTV Lite", "Backup Complete", 1000, THUMB))
Exemplo n.º 39
0
    def storeFiles(self):
        self.log('storeFiles')

        if CHANNEL_SHARING == False:
            return

        realloc = ADDON.getSetting('SettingsFolder')
        FileAccess.copy(SETTINGS_LOC + '/settings2.xml', realloc + '/settings2.xml')
        realloc = xbmc.translatePath(os.path.join(realloc, 'cache')) + '/'

        for i in range(self.maxChannels + 1):
            FileAccess.copy(CHANNELS_LOC + 'channel_' + str(i) + '.m3u', realloc + 'channel_' + str(i) + '.m3u')
Exemplo n.º 40
0
 def SetDefaultArt(self, chname, arttype):
     self.log('SetDefaultArt')
     setImage = ''
     ChannelLogo = os.path.join(LOGO_LOC, chname[0:18] + '.png')
     MediaImage = os.path.join(MEDIA_LOC, (arttype + '.png'))
     if FileAccess.exists(ChannelLogo):
         setImage = ChannelLogo
     elif FileAccess.exists(MediaImage):
         setImage = MediaImage
     else:
         setImage = THUMB
     return setImage
Exemplo n.º 41
0
def addFont(fntname, filename, size, style=""):
    log("MyFont: addFont, filename = " + filename + ", size = " + size)
    FontName = filename
    FontPath = os.path.join(PTVL_SELECT_SKIN_LOC, 'fonts', FontName)
    log("MyFont: addFont, FontName = " + FontName)
    log("MyFont: addFont, FontPath = " + FontPath)
    reload_skin = False
    fontxml_paths = getFontsXML()
    if fontxml_paths:
        for fontxml_path in fontxml_paths:
            if not isFontInstalled(fontxml_path, fntname, FontName):
                parser = PCParser()
                tree = ET.parse(fontxml_path, parser=parser)
                root = tree.getroot()
                for sets in root.getchildren():
                    sets.findall("font")[-1].tail = "\n\t\t"
                    new = ET.SubElement(sets, "font")
                    new.text, new.tail = "\n\t\t\t", "\n\t"
                    subnew1 = ET.SubElement(new, "name")
                    subnew1.text = fntname
                    subnew1.tail = "\n\t\t\t"
                    subnew2 = ET.SubElement(new, "filename")
                    subnew2.text = (
                        filename,
                        "Arial.ttf")[sets.attrib.get("id") == "Arial"]
                    subnew2.tail = "\n\t\t\t"
                    subnew3 = ET.SubElement(new, "size")
                    subnew3.text = size
                    subnew3.tail = "\n\t\t\t"
                    last_elem = subnew3
                    if style in ["normal", "bold", "italics", "bolditalics"]:
                        subnew4 = ET.SubElement(new, "style")
                        subnew4.text = style
                        subnew4.tail = "\n\t\t\t"
                        last_elem = subnew4
                    reload_skin = True
                    last_elem.tail = "\n\t\t"
                tree.write(fontxml_path)
                reload_skin = True

        if os.path.exists(SkinPath) == False:
            reload_skin = True

        dest = os.path.join(SkinPath, 'fonts', FontName)
        if os.path.exists(dest) == False:
            log("MyFont: copyFont, FontPath = " + FontPath + ", SkinPath = " +
                SkinPath)
            FileAccess.copy(FontPath, dest)

    if reload_skin:
        xbmc.executebuiltin("XBMC.ReloadSkin()")
        return True
    return False
Exemplo n.º 42
0
def Backup(org, bak):
    log('Backup ' + str(org) + ' - ' + str(bak))
    if FileAccess.exists(org):
        if FileAccess.exists(bak):
            try:
                xbmcvfs.delete(bak)
            except:
                pass
        FileAccess.copy(org, bak)
    
    if DEBUG == 'true':
        xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoTV Lite", "Backup Complete", 1000, THUMB) )
Exemplo n.º 43
0
    def onAction(self, act):
        action = act.getId()

        if action in ACTION_PREVIOUS_MENU:
            if self.showingList == False:
                self.cancelChan()
                self.hideChanDetails()
            else:
                if self.madeChanges == 1:
                    dlg = xbmcgui.Dialog()

                    if dlg.yesno(xbmc.getLocalizedString(190),
                                 LANGUAGE(30032)):
                        ADDON_SETTINGS.writeSettings()

                        if CHANNEL_SHARING:
                            realloc = ADDON.getSetting('SettingsFolder')
                            FileAccess.copy(SETTINGS_LOC + '/settings2.xml',
                                            realloc + '/settings2.xml')
                self.close()
        elif action == CONTEXT_MENU:
            curchan = self.listcontrol.getSelectedPosition() + 1
            AffectChannelOptions = ("Copy Channel", "Swap Channels",
                                    "Insert Channel (and move down)",
                                    "Delete Channel (and move up)",
                                    "Clear Channel")
            ChannelAction = xbmcgui.Dialog().select(
                "Choose An Action For Channel %d" % curchan,
                AffectChannelOptions)
            if ChannelAction != -1:
                if ChannelAction == 0:
                    CopyToChannel = int(xbmcgui.Dialog().numeric(
                        0, "Copy To (and overwrite) Channel"))
                    if 1 <= CopyToChannel <= 9999:
                        self.copyChannel(curchan, CopyToChannel)
                elif ChannelAction == 1:
                    SwapToChannel = int(xbmcgui.Dialog().numeric(
                        0, "Swap Channel %d with Channel:" % curchan))
                    if 1 <= SwapToChannel <= 9999:
                        firstEmpty = self.findFirstEmpty(curchan)
                        self.swapChannel(curchan, SwapToChannel, firstEmpty)
                elif ChannelAction == 2:
                    firstEmpty = self.findFirstEmpty(curchan)
                    self.insertChannel(curchan, firstEmpty)
                    #xbmc.executebuiltin('Notification(%s,%s)' % (curchan,FirstEmpty))
                elif ChannelAction == 3:
                    firstEmpty = self.findFirstEmpty(curchan)
                    self.deleteChannel(curchan, firstEmpty)
                elif ChannelAction == 4:
                    self.clearChannel(curchan)
        elif act.getButtonCode() == 61575:  # Delete button
            curchan = self.listcontrol.getSelectedPosition() + 1
            self.clearChannel(curchan)
Exemplo n.º 44
0
 def __init__(self, filename, query_dict, top_k=12, n=5, clean=True):
     r = Retriever()
     if not clean:
         self.total_corpus = r.get_total_corpus(folder='stopped')
     else:
         self.total_corpus = r.get_total_corpus(folder='clean')
     self.k = top_k
     self.n = n
     fa = FileAccess()
     self.query_dict = query_dict
     self.results = fa.read_result_file(filename=filename)
     return
Exemplo n.º 45
0
    def get_stopped_queries(self, query_dict):
        fa = FileAccess()
        query_dict = query_dict
        stop_words = fa.get_stop_words()
        stopped_queries = {}
        for each in query_dict:
            query = query_dict[each]
            query_list = query.split()
            stopped_query = [x for x in query_list if x not in stop_words]
            stopped_query = " ".join(stopped_query)
            stopped_queries[each] = stopped_query

        return stopped_queries
Exemplo n.º 46
0
def addFont(fntname, filename, size, style=""):
    log("MyFont: addFont, filename = " + filename + ", size = " + size)
    FontName = filename
    FontPath = os.path.join(PTVL_SELECT_SKIN_LOC, 'fonts', FontName)
    log("MyFont: addFont, FontName = " + FontName)
    log("MyFont: addFont, FontPath = " + FontPath)
    reload_skin = False
    fontxml_paths = getFontsXML()
    if fontxml_paths:
        for fontxml_path in fontxml_paths:
            if not isFontInstalled(fontxml_path, fntname, FontName):
                parser = PCParser()
                tree = ET.parse(fontxml_path, parser=parser)
                root = tree.getroot()
                for sets in root.getchildren():
                    sets.findall("font")[-1].tail = "\n\t\t"                        
                    new = ET.SubElement(sets, "font")
                    new.text, new.tail = "\n\t\t\t", "\n\t"
                    subnew1 = ET.SubElement(new, "name")
                    subnew1.text = fntname
                    subnew1.tail = "\n\t\t\t"
                    subnew2 = ET.SubElement(new, "filename")
                    subnew2.text = (filename, "Arial.ttf")[sets.attrib.get("id") == "Arial"]
                    subnew2.tail = "\n\t\t\t"
                    subnew3 = ET.SubElement(new, "size")
                    subnew3.text = size
                    subnew3.tail = "\n\t\t\t"
                    last_elem = subnew3
                    if style in ["normal", "bold", "italics", "bolditalics"]:
                        subnew4 = ET.SubElement(new, "style")
                        subnew4.text = style
                        subnew4.tail = "\n\t\t\t"
                        last_elem = subnew4
                    reload_skin = True
                    last_elem.tail = "\n\t\t"
                tree.write(fontxml_path)
                reload_skin = True
                
        if os.path.exists(SkinPath) == False:
            reload_skin = True
            
        dest = os.path.join(SkinPath, 'fonts', FontName)
        if os.path.exists(dest) == False:
            log("MyFont: copyFont, FontPath = " + FontPath + ", SkinPath = " + SkinPath)
            FileAccess.copy(FontPath, dest)
    
    if reload_skin:
        xbmc.executebuiltin("XBMC.ReloadSkin()")
        return True
    return False
Exemplo n.º 47
0
    def DownloadArt(self, type, id, fle, typeEXT, ART_LOC):
        print ('DownloadArt')
        tvdbAPI = TVDB(TVDB_API_KEY)
        tmdbAPI = TMDB(TMDB_API_KEY)     
        
        if not FileAccess.exists(ART_LOC):
            FileAccess.makedirs(ART_LOC)

        ArtType = typeEXT.split('.')[0]        
        setImage = ''
        
        if type.lower() == 'tvshow':
            FanTVDownload = False
            TVFilePath = os.path.join(ART_LOC, fle) 
            tvdb_Types = ['banner', 'fanart', 'folder', 'poster']
            
            if ArtType in tvdb_Types:
                ArtType = ArtType.replace('banner', 'graphical').replace('folder', 'poster')
                tvdb = str(tvdbAPI.getBannerByID(id, ArtType))
                try:
                    tvdbPath = tvdb.split(', ')[0].replace("[('", "").replace("'", "") 
                    resource = urllib.urlopen(tvdbPath)
                    output = FileAccess.open(TVFilePath, 'w')
                    output.write(resource.read())
                    output.close()
                    return TVFilePath
                except Exception,e:
                    FanTVDownload = True
                    print ('tvdbAPI Failed!') 
                    pass
            else:
                FanTVDownload = True

            if FanTVDownload == True:
                ArtType = ArtType.replace('graphical', 'banner').replace('folder', 'poster').replace('fanart', 'tvfanart')
                fan = fanarttv.get_image_list_TV(id)
                try:
                    data = str(fan).replace("[", "").replace("]", "").replace("'", "")
                    data = data.split('}, {')
                    fanPath = str([s for s in data if ArtType in s]).split("', 'art_type: ")[0]
                    match = re.search("url *: *(.*?),", fanPath)
                    fanPath = match.group().replace(",", "").replace("url: u", "").replace("url: ", "")
                    resource = urllib.urlopen(fanPath)
                    output = FileAccess.open(TVFilePath, 'w')
                    output.write(resource.read())
                    output.close()
                    return TVFilePath
                except Exception,e:
                    print ('FanTVDownload Failed!') 
                    return ''   
Exemplo n.º 48
0
    def backupFiles(self, updatedlg):
        self.log('backupFiles')

        if CHANNEL_SHARING == False:
            return

        updatedlg.update(1, "Initializing", "Copying Channels...")
        realloc = REAL_SETTINGS.getSetting('SettingsFolder')
        FileAccess.copy(realloc + '/settings2.xml', SETTINGS_LOC + '/settings2.xml')
        realloc = xbmc.translatePath(os.path.join(realloc, 'cache')) + '/'

        for i in range(999):
            FileAccess.copy(realloc + 'channel_' + str(i) + '.m3u', CHANNELS_LOC + 'channel_' + str(i) + '.m3u')
            updatedlg.update(int(i * .07) + 1, "Initializing", "Copying Channels...")
Exemplo n.º 49
0
    def setShowInfo(self):
        self.log('setShowInfo')
        basex, basey = self.getControl(111 + self.focusRow).getPosition()
        baseh = self.getControl(111 + self.focusRow).getHeight()
        basew = self.getControl(111 + self.focusRow).getWidth()
        # use the selected time to set the video
        left, top = self.channelButtons[self.focusRow][self.focusIndex].getPosition()
        width = self.channelButtons[self.focusRow][self.focusIndex].getWidth()
        left = left - basex + (width / 2)
        starttime = self.shownTime + (left / (basew / 5400.0))
        chnoffset = self.focusRow - 2
        newchan = self.centerChannel

        while chnoffset != 0:
            if chnoffset > 0:
                newchan = self.MyOverlayWindow.fixChannel(newchan + 1, True)
                chnoffset -= 1
            else:
                newchan = self.MyOverlayWindow.fixChannel(newchan - 1, False)
                chnoffset += 1

        plpos = self.determinePlaylistPosAtTime(starttime, newchan)

        if plpos == -1:
            self.log('Unable to find the proper playlist to set from EPG')
            return

        self.getControl(500).setLabel(self.MyOverlayWindow.channels[newchan - 1].getItemTitle(plpos))
        self.getControl(501).setLabel(self.MyOverlayWindow.channels[newchan - 1].getItemEpisodeTitle(plpos))
        self.getControl(502).setLabel(self.MyOverlayWindow.channels[newchan - 1].getItemDescription(plpos))
        self.getControl(503).setImage(self.channelLogos + ascii(self.MyOverlayWindow.channels[newchan - 1].name) + '.png')
        if not FileAccess.exists(self.channelLogos + ascii(self.MyOverlayWindow.channels[newchan - 1].name) + '.png'):
            self.getControl(503).setImage(IMAGES_LOC + 'Default.png')
        self.log('setShowInfo return')
Exemplo n.º 50
0
 def DownloadMetaArt(self, type, fle, id, typeEXT, ART_LOC):
     print ('DownloadMetaArt')
     ArtPath = os.path.join(ART_LOC, fle)
     
     if type == 'tvshow':
         Tid = id
         Mid = ''
     else:
         Mid = id
         Tid = ''
         
     typeEXT = typeEXT.split('.')[0]
     typeEXT = typeEXT.replace('landscape','backdrop_url').replace('fanart','backdrop_url').replace('logo','backdrop_url').replace('clearart','backdrop_url').replace('poster','cover_url').replace('banner','banner_url')
     
     # try:
     print 'metahander'
     self.metaget = metahandlers.MetaData(preparezip=False)
     ImageURL = str(self.metaget.get_meta(type, '', imdb_id=str(Mid), tmdb_id=str(Tid)))[typeEXT]
     resource = urllib.urlopen(ImageURL)
     output = FileAccess.open(ArtPath, 'w')
     output.write(resource.read())
     output.close()
     setImage = ArtPath
     # except:
         # pass
         
     return setImage
Exemplo n.º 51
0
 def DownloadMetaArt(self, type, fle, id, typeEXT, ART_LOC):
     self.log('DownloadMetaArt')
     ArtPath = os.path.join(ART_LOC, fle)
     setImage = ''
     
     if type == 'tvshow':
         Tid = id
         Mid = ''
     else:
         Mid = id
         Tid = ''
         
     typeEXT = typeEXT.split('.')[0]
     typeEXT = typeEXT.replace('landscape','backdrop_url').replace('fanart','backdrop_url').replace('logo','backdrop_url').replace('clearart','backdrop_url').replace('poster','cover_url').replace('banner','banner_url')
     try:
         self.log('DownloadMetaArt, metahander')
         self.metaget = metahandlers.MetaData(preparezip=False)
         ImageURL = str(self.metaget.get_meta(type, '', imdb_id=str(Mid), tmdb_id=str(Tid)))[typeEXT]
         resource = urllib.urlopen(ImageURL)
         output = FileAccess.open(ArtPath, 'w')
         output.write(resource.read())
         output.close()
         setImage = ArtPath
     except Exception,e:  
         self.log("script.pseudotv.live-Artdownloader: DownloadMetaArt Failed" + str(e), xbmc.LOGERROR) 
         self.log(traceback.format_exc(), xbmc.LOGERROR)
Exemplo n.º 52
0
    def migrate(self):
        self.log("migrate")
        settingsFile = xbmc.translatePath(os.path.join(Globals.SETTINGS_LOC, 'settings2.xml'))    
        chanlist = ChannelList.ChannelList()
        chanlist.background = True
        chanlist.forceReset = True
        chanlist.createlist = True
        
        # If Autotune is enabled direct to autotuning
        if Globals.REAL_SETTINGS.getSetting("Autotune") == "true" and Globals.REAL_SETTINGS.getSetting("Warning1") == "true":
            self.log("autoTune, migrate")
            if self.autoTune():
                return True
        else:
            if FileAccess.exists(settingsFile):
                return False
            else:
                currentpreset = 0

            for i in range(Globals.TOTAL_FILL_CHANNELS):
                chantype = 9999

                try:
                    chantype = int(Globals.ADDON_SETTINGS.getSetting("Channel_" + str(i + 1) + "_type"))
                except:
                    pass

                if chantype == 9999:
                    self.log("addPreset")
                    self.addPreset(i + 1, currentpreset)
                    currentpreset += 1
                    
        return True
Exemplo n.º 53
0
 def save(self, filename):
     self.log("save " + filename)
     try:
         fle = FileAccess.open(filename, 'w')
     except Exception,e:
         self.log("save Unable to open the smart playlist", xbmc.LOGERROR)
         return
Exemplo n.º 54
0
    def createShowPlaylist(self, show, setting2):
        order = 'random'

        try:
            setting = int(setting2)

            if setting & MODE_ORDERAIRDATE > 0:
                order = 'airdate'
        except:
            pass

        flename = xbmc.makeLegalFilename(GEN_CHAN_LOC + 'Show_' + show + '_' + order + '.xsp')

        try:
            fle = FileAccess.open(flename, "w")
        except:
            self.Error('Unable to open the cache file ' + flename, xbmc.LOGERROR)
            return ''

        self.writeXSPHeader(fle, 'episodes', self.getChannelName(6, show))
        show = self.cleanString(show)
        fle.write('    <rule field="tvshow" operator="is">' + show + '</rule>\n')
        self.writeXSPFooter(fle, 0, order)
        fle.close()
        return flename
Exemplo n.º 55
0
    def determineLength(self, filename):
        self.log("determineLength " + filename)
        self.pid = -1

        try:
            self.File = FileAccess.open(filename, "rb", None)
        except:
            self.log("Unable to open the file")
            return

        self.filesize = self.getFileSize()
        self.packetLength = self.findPacketLength()

        if self.packetLength <= 0:
            return 0

        start = self.getStartTime()
        self.log('Start - ' + str(start))
        end = self.getEndTime()
        self.log('End - ' + str(end))

        if end > start:
            dur = int((end - start) / 90000)
        else:
            dur = 0

        self.File.close()
        self.log("Duration: " + str(dur))
        return dur
Exemplo n.º 56
0
    def getVideoLength(self, filename):
        self.log("getVideoLength " + filename)

        if len(filename) == 0:
            self.log("No file name specified")
            return 0

        if FileAccess.exists(filename) == False:
            self.log("Unable to find the file")
            return 0

        base, ext = os.path.splitext(filename)
        ext = ext.lower()

        if ext in self.AVIExts:
            self.parser = AVIParser.AVIParser()
        elif ext in self.MP4Exts:
            self.parser = MP4Parser.MP4Parser()
        elif ext in self.MKVExts:
            self.parser = MKVParser.MKVParser()
        elif ext in self.FLVExts:
            self.parser = FLVParser.FLVParser()
        elif ext in self.TSExts:
            self.parser = TSParser.TSParser()
        else:
            self.log("No parser found for extension " + ext)
            return 0

        return self.parser.determineLength(filename)
Exemplo n.º 57
0
    def createNetworkPlaylist(self, network):
        flename = xbmc.makeLegalFilename(GEN_CHAN_LOC + 'Network_' + network + '.xsp')

        try:
            fle = FileAccess.open(flename, "w")
        except:
            self.Error('Unable to open the cache file ' + flename, xbmc.LOGERROR)
            return ''

        self.writeXSPHeader(fle, "episodes", self.getChannelName(1, network))
        network = network.lower()
        added = False

        for i in range(len(self.showList)):
            if self.threadPause() == False:
                fle.close()
                return ''

            if self.showList[i][1].lower() == network:
                theshow = self.cleanString(self.showList[i][0])
                fle.write('    <rule field="tvshow" operator="is">' + theshow + '</rule>\n')
                added = True

        self.writeXSPFooter(fle, 0, "random")
        fle.close()

        if added == False:
            return ''

        return flename