示例#1
0
    def get_tvshows(self, page=1):
        tvshows = []

        re_sub_box = "<a href=\"/sub.asp\?sub_id=(?P<id>\d+)\""
        re_series = "<div class=\"sub_tbox\".*?{0}.*?</div>".format(re_sub_box)

        re_imdb = "<a href=\"http\://www\.imdb\.com/title/tt(?P<imdbid>\d+)/"
        re_sub_rank = "<div class=\"sub_rank_div\".*?{0}.*?</div>".format(re_imdb)

        try:
            page_content = str(client.request(self.torec_link % page))
            for item in re.finditer(re_series, page_content, re.DOTALL):
                import xbmc
                import sys
                if xbmc.abortRequested:
                    return sys.exit()
                series_link = self.torec_series_link % str(item.group('id').strip())
                series_content = str(client.request(series_link))
                for series_item in re.finditer(re_sub_rank, series_content, re.DOTALL):
                    import xbmc
                    import sys
                    if xbmc.abortRequested:
                        return sys.exit()
                    imdbid = "tt" + series_item.group('imdbid').strip()
                    tvshow = {}
                    try:
                        import hashlib
                        tvshowhash = "torec::" + hashlib.sha224("%s" % (imdbid)).hexdigest()
                        fromcache = cache.get(tvshowhash)
                        if fromcache is not None:
                            tvshow = eval(fromcache[1].encode('utf-8'))
                            tvshow['cached'] = "true"
                        else:
                            from libra.imdb import imdb
                            imdb_data = imdb(imdbid=imdbid)
                            tvshow['title'] = imdb_data.get_title()
                            tvshow['year'] = imdb_data.get_year()
                            tvshow['imdbid'] = imdb_data.get_imdbid()
                            tvshow['runtime'] = imdb_data.get_runtime()
                            tvshow['rating'] = imdb_data.get_rating()
                            tvshow['genres'] = imdb_data.get_genres()
                            tvshow['name'] = "%s (%s)" % (tvshow['title'], tvshow['year'])

                            from libra.tvdb import tvdb
                            tvdb_data = tvdb(imdbid=imdbid)
                            tvshow['tvdb'] = tvdb_data.get_seriesid()

                            cache.set(tvshowhash, tvshow)

                    except:
                        continue

                    tvshows.append(tvshow)
        except Exception, e:
            import xbmc
            import traceback
            map(xbmc.log, traceback.format_exc().split("\n"))
            raise
示例#2
0
    def get_movies(self, page=1):
        movies = []

        re_movie_anchor = "<a href=\"view.php\?id=(?P<id>\d+)#\d+\" title=\"(?P<nameHe>.*?)\|(?P<nameEn>.*?)\|(?P<year>.*?)\""
        re_movie = "<table.*?{0}.*?Israel-Flag.png.*?</table>".format(re_movie_anchor)

        try:
            page_content = str(client.request(self.ktuvit_link % page))
            for item in re.finditer(re_movie, page_content, re.DOTALL):
                import xbmc
                import sys
                if xbmc.abortRequested:
                    return sys.exit()
                movie = {'title': item.group('nameEn').strip(), 'year': item.group('year').strip()}
                movie['name'] = "%s (%s)" % (movie['title'], movie['year'])
                try:
                    import hashlib
                    moviehash = "ktuvit::" + hashlib.sha224("%s (%s)" % (movie['title'], movie['year'])).hexdigest()
                    fromcache = cache.get(moviehash)
                    if fromcache is not None:
                        movie = eval(fromcache[1].encode('utf-8'))
                        movie['cached'] = "true"
                    else:
                        from libra.imdb import imdb
                        imdb_data = imdb(title=movie['title'], year=movie['year'])
                        if imdb_data.imdb_data.get('Error'):
                            continue
                        movie['imdbid'] = imdb_data.get_imdbid()
                        movie['runtime'] = imdb_data.get_runtime()
                        movie['rating'] = imdb_data.get_rating()
                        movie['genres'] = imdb_data.get_genres()

                        cache.set(moviehash, movie)

                except:
                    continue

                movies.append(movie)

        except Exception, e:
            import xbmc
            import traceback
            map(xbmc.log, traceback.format_exc().split("\n"))
            raise