예제 #1
0
 def __init__(self, id=None ):
   self.addon   = xbmcaddon.Addon() if id == None else xbmcaddon.Addon(id=id)
   self.name    = Text.xbmcFrom( self.addon.getAddonInfo("name"   ) )
   self.version = Text.xbmcFrom( self.addon.getAddonInfo("version") )
   self.id      = Text.xbmcFrom( self.addon.getAddonInfo("id"     ) )
   self.path    = Text.xbmcFrom( self.addon.getAddonInfo("path"   ) )
   self.data    = Text.xbmcFrom( xbmc.translatePath('special://profile/addon_data/%s' % (self.id)) )
   self.config  = Config(self.addon)
   self.tracker = GaTracker()
   sm.addon     = self.addon
   self.initPaths()
예제 #2
0
 def asExodus(self):
   params = {}
   params['action'] = 'play'
   params['title' ] = self.nameEn
   params['imdb'  ] = self.idImdb[2:]
   params['year'  ] = self.year
   return Text.buildUrl('plugin://plugin.video.exodus/' , params )
예제 #3
0
 def load(source, target='', timeout=0, proxy=Cache.Enabled, contentType= '', retries=0, onDownloading = None, params = {} , loadData = True, maxCache=0):
   fileLoader = FileLoader()
   fileLoader.onDownloading = onDownloading
   if len(params) > 0:
     source = Text.buildUrl(source,params)
   fileLoader.loadFile(source, target, timeout, proxy, contentType, retries, loadData, maxCache)
   return fileLoader
예제 #4
0
 def loadEpisodes(self, lang="en", updateNow=False):
     try:
         downloadAll = updateNow or self.loadTvdbInfo(lang=lang)
         if downloadAll:
             ff = FileLoader.load(
                 "http://thetvdb.com/api/1D62F2F90030C444/series/{0}/all/en.zip".format(self.tvdbId), loadData=False
             )
             if ff.state != FileLoader.idOk:
                 return False
             zf = zipfile.ZipFile(ff.target)
             root = et.fromstring(zf.read("en.xml"))
             for ndEpisode in root.findall("Episode"):
                 season = int(ndEpisode.find("./SeasonNumber").text)
                 episode = int(ndEpisode.find("./EpisodeNumber").text)
                 name = ndEpisode.find("./EpisodeName").text
                 # airdate = ndEpisode.find('./FirstAired').text
                 if not ndEpisode.find("./FirstAired").text == None:
                     airdate = ndEpisode.find("./FirstAired").text
                 else:
                     airdate = ""
                 self.episodes.append(EpisodeInfo(self, season, episode, name, airdate))
             return True
         else:
             pass
     except Exception, ee:
         Log.log(Text.formatException(ee))
예제 #5
0
 def findCachedName(self, source, target, isCached):
   sum = Text.hash(source,12) if isCached else '000000000000'
   if target == '':
     return os.path.join( FileLoader.dirCache , 'file_{0}.bin'.format(sum) )
   if target.startswith('@'):
     return target[1:]
   extIndex = target.rfind('.')
   if extIndex != -1:
     return os.path.join( FileLoader.dirCache , u'{0}_{1}{2}'.format(target[:extIndex],sum,target[extIndex:]) )
   return os.path.join( FileLoader.dirCache , '{0}_{1}{2}'.format(target, sum,'.bin') )
예제 #6
0
 def asExodus(self):
     params = {}
     params["action"] = "play"
     params["title"] = self.name
     params["year"] = self.owner.year
     params["imdb"] = self.owner.imdbId[2:] if self.owner.imdbId != None else ""
     params["tvdb"] = self.owner.tvdbId
     params["season"] = self.season
     params["episode"] = self.episode
     params["tvshowtitle"] = self.owner.name
     params["premiered"] = self.airdate
     return Text.buildUrl("plugin://plugin.video.exodus/", params)
예제 #7
0
 def asSalts(self):
   """
   Create url for Salt addon
   """
   params = {}
   params['title'     ] = self.nameEn
   params['video_type'] = 'Movie'
   params['trakt_id'] = self.traktId
   params['mode'      ] = 'get_sources'
   params['dialog'    ] = True
   params['year'      ] = self.year
   #params['slug'      ] = u'{0}-{1}'.format(self.nameEn.replace(' ','-').lower(), self.year)
   return Text.buildUrl('plugin://plugin.video.salts/' , params )
예제 #8
0
    def save(self, dirTarget, langid=7, withThumb=False, streamMode=StreamMode.Exodus):
        added = 0
        episodes = 0
        base = File.cleanName(u"{0} ({1})".format(self.name.lower(), self.year))
        dirSeries = os.path.join(dirTarget, base)
        self.saveTvdbInfo()
        if os.path.exists(dirSeries) == False:
            added += 1
        self.saveTvshow(dirSeries, langid=langid)
        episodes = 0
        for episode in self.episodes:
            try:
                if episode.season == 0:
                    continue
                if episode.name == "TBA":
                    continue
                dirSeason = os.path.join(
                    dirSeries, File.cleanName(u"{0}.S{1:02}".format(self.findNameClean(), episode.season))
                )
                self.saveTvshow(dirSeason, langid=langid)

                name = u"{3}.S{0:02}E{1:02}.{2}".format(episode.season, episode.episode, episode.name, self.name)

                part0 = dirSeason
                part1 = self.name
                part2 = ".S{0:02}E{1:02}.".format(episode.season, episode.episode)
                part3 = episode.name[: 256 - -len(part0) - len(part1) - len(part2) - 10]

                base = File.cleanName(u"{0}{1}{2}".format(part1, part2, part3))

                links = []
                if streamMode == StreamMode.Exodus:
                    links.append([name, episode.asExodus()])
                if streamMode == StreamMode.Pulsar:
                    links.append([name, episode.asPulsar()])

                if streamMode == StreamMode.Salts:
                    links.append([name, episode.asSalts()])
                if streamMode == StreamMode.Quasar:
                    links.append([name, episode.asQuasar()])

                strm = os.path.join(dirSeason, u"{0}.{1}".format(base, "strm"))
                if os.path.exists(strm) == False:
                    episodes += 1
                with codecs.open(strm, "w") as ff:
                    ff.write("#EXTM3U\n")
                    for xx in links:
                        ff.write(u"#EXTINF:{0},{1}\n".format(0, xx[0]))
                        ff.write(u"{0}\n".format(xx[1]))
            except Exception, ee:
                Log.log(Text.formatException(ee))
예제 #9
0
    def asSalts(self):

        params = {}
        params["ep_airdate"] = self.airdate
        params["trakt_id"] = self.owner.traktId
        params["episode"] = self.episode
        params["mode"] = "get_sources"
        params["dialog"] = "True"
        params["title"] = self.owner.name
        params["ep_title"] = self.name
        params["season"] = self.season
        params["video_type"] = "Episode"
        params["year"] = self.owner.year
        # params['slug'      ]=self.owner.name.replace(' ','-').lower()
        return Text.buildUrl("plugin://plugin.video.salts/", params)
예제 #10
0
 def loadTmdbId(self):
     if self.tmdbId != None:
         return True
     if self.imdbId == None:
         self.loadImdb(self)
     #   Log.log('http://api.themoviedb.org/3/find/' + self.imdbId + '?api_key=e675b61c515daa2b18932147aa0653ec&external_source=imdb_id')
     request = Request(
         "http://api.themoviedb.org/3/find/"
         + self.imdbId
         + "?api_key=e675b61c515daa2b18932147aa0653ec&external_source=imdb_id"
     )
     try:
         response = urlopen(request)
     except Exception, ee:
         Log.log(Text.formatException(ee))
         return False
예제 #11
0
 def loadTraktId(self):
     if self.traktId != None:
         return True
     if self.imdbId == None:
         self.loadImdb(self)
     headers = {
         "Content-Type": "application/json",
         "trakt-api-version": "2",
         "trakt-api-key": "9732c09aadf88f287e38cab293fe5732facbb236595ac93d6036b3ce459eb1f2",
     }
     request = Request("https://api-v2launch.trakt.tv/search?id_type=imdb&id=" + self.imdbId, headers=headers)
     try:
         response = urlopen(request)
     except Exception, ee:
         Log.log(Text.formatException(ee))
         return False
예제 #12
0
 def loadTraktId(self):
   if self.traktId != None:
     return True
   if self.idImdb == None:
     return False
   headers = {
     'Content-Type': 'application/json',
     'trakt-api-version': '2',
     'trakt-api-key': '9732c09aadf88f287e38cab293fe5732facbb236595ac93d6036b3ce459eb1f2'
   }
   request = Request('https://api-v2launch.trakt.tv/search?id_type=imdb&id=' + self.idImdb, headers=headers)
   try:
     response = urlopen(request)
   except Exception, ee:
     Log.log(Text.formatException(ee))
     return False
예제 #13
0
 def loadImdb(self):
     try:
         if self.imdbInfo != {}:
             return True
         params = {}
         if self.imdbId != None:
             params["i"] = self.imdbId
         else:
             params["t"] = self.name
             params["y"] = self.year
         ff = FileLoader.load("http://www.omdbapi.com/", params=params)
         info = json.loads(ff.data)
         if info.get("Response") == "False":
             return False
         self.initImdbInfo(info)
         self.loadTraktId()
         self.loadTmdbId()
         return True
     except Exception, ee:
         Log.log(Text.formatException(ee))
         return False
예제 #14
0
 def notify(self,message):
   if self.config.getBool('notify'):
     xbmc.executebuiltin(Text.xbmcTo(u'XBMC.Notification({0},{1},{2},{3})'.format(self.name, message , 5 , os.path.join( self.path ,"icon.png" ))) )
예제 #15
0
 def message(self,title,message):
   xbmcgui.Dialog().ok( Text.xbmcTo(title), Text.xbmcTo(message) )
예제 #16
0
 def initNameYearId(self, name, year, imdbId):
     self.name = Text.unescapeHtml(name.strip())
     self.year = int(year.strip())
     self.imdbId = imdbId.strip()
     return self
예제 #17
0
 def __init__(self,nameHe,nameEn,year,id):
   self.nameHe     = Text.unescapeHtml(nameHe.strip())
   self.nameEn     = Text.unescapeHtml(nameEn.strip())
   self.year       = int(year.strip())
   self.idSubtitle = id.strip()
   self.traktId = None