Пример #1
0
def scrape_xspf(body):
    all_track = regex_get_all(body, '<track>', '</track>')
    tracks = []
    for track in all_track:
        name = regex_from_to(track, '<title>', '</title>')
        location = regex_from_to(track, '<location>', '</location>')
        tracks.append({'name': name, 'location': location})
    return tracks
Пример #2
0
 def poster(self):
     try:
         first_poster = regex_from_to(self.info_result, 'posters":', '},')
         path = regex_from_to(first_poster, 'file_path":"', '",')
         url = base_url + POSTER_QUALITY + path
     except:
         try:
             path = regex_from_to(self.info_result, 'poster_path":"', '",')
             url = base_url + POSTER_QUALITY + path
         except:
             url = None
     return url
Пример #3
0
 def fanart(self):
     try:
         first_fanart = regex_from_to(self.info_result, 'backdrops":', '},')
         path = regex_from_to(first_fanart, 'file_path":"', '",')
         url = base_url + FANART_QUALITY + path
     except:
         try:
             path = regex_from_to(self.info_result, 'backdrop_path":"',
                                  '",')
             url = base_url + FANART_QUALITY + path
         except:
             url = None
     return url
Пример #4
0
def get_imdb_search_result(body):
    all_tr = regex_get_all(body, '<tr class=', '</tr>')
    
    movies = []
    for tr in all_tr:
        all_td = regex_get_all(tr, '<td', '</td>')
        imdb_id = regex_from_to(all_td[1], '/title/', '/')
        name = regex_from_to(all_td[1], '/">', '</a>')
        year = regex_from_to(all_td[1], '<span class="year_type">\(', '\)')
        rating = regex_from_to(all_td[2], '<b>', '</b>')
        votes = regex_from_to(all_td[3], '\n', '\n')
        movies.append({'imdb_id': imdb_id, 'name': name, 'year': year, 'rating': rating, 'votes': votes})
    return movies            
Пример #5
0
def repositories(addon_name):
    dialog = xbmcgui.Dialog()
    list = []
    repo_list = []
    dp = xbmcgui.DialogProgress()
    dp.create('Repository')
    directories = os.listdir(check_path)
    count = 0
    for d in directories:
        if d.startswith('repository'):
            addonpath = os.path.join(check_path, d)
            percent = 25
            dp.update(percent, "Scanning installed repositories")
            for file in glob.glob(os.path.join(addonpath, "addon.xml")):
                text = read_from_file(file)
                repo_url = regex_from_to(text, '<datadir zip="true">', '</datadir>')
                req = urllib2.Request(repo_url)
                percent = 50
                dp.update(percent, "Fetching repository addon information")
                req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
                try:
                    response = urllib2.urlopen(req)
                    link=response.read()
                    response.close()
                    if repo_url.find('bitbucket') > 0:
                        match = re.compile('class="pjax-trigger execute"><span class="aui-icon aui-icon-small aui-iconfont-devtools-folder-closed"></span>(.+?)</a>').findall(link)
                    else:
                        match = re.compile('<a href="(.+?)/">').findall(link)
	                nItem = len(match)
                    for addons in match:
                        if addons.startswith('plugin') or addons.startswith('script') or addons.startswith('skin') or addons.startswith('metadata'):
                            percent = 75
                            dp.update(percent, "Matching addon to repository")
                            repo_list.append("<<%s/%s>>" % (addons, d))
                except:
                    pass
    
    if str(repo_list).find(addon_name) > 0:
        repo_name = regex_from_to(str(repo_list), addon_name + "/", ">>")
        repo_path = os.path.join(check_path, repo_name)
        if os.path.exists(repo_path):
            shutil.rmtree(repo_path)
            percent = 100
            dp.update(percent, "Repository removed")
            time.sleep(1)
        else:
            dialog.ok(repo_name, "", "No repository found")
    else:
            dialog.ok(repo_name, "", "No repository found")
Пример #6
0
 def certification(self):
     try:
         n = regex_from_to(self.info_result,
                           'iso_3166_1":"US","certification":"', '",')
     except:
         n = None
     return n
Пример #7
0
 def categories(self):
     try:
         text = regex_from_to(self.info_result, 'genres"', ',"homepage')
         r = re.compile('name":"(.+?)"').findall(text)
     except:
         r = None
     return r
Пример #8
0
 def __init__(self, movie_name=None, imdb_id=None):
     self.api_key = API_KEY
     if imdb_id:
         self.imdb_id = imdb_id
     else:
         search_url = 'http://api.themoviedb.org/2.1/Movie.search/en/xml/' + self.api_key + '/' + urllib2.quote(movie_name)
         search_result = get_url(search_url)
         self.imdb_id = regex_from_to(search_result, '<id>', '</id>')
     info_url = 'http://api.themoviedb.org/2.1/Movie.imdbLookup/en/xml/' + self.api_key + '/' + self.imdb_id
     self.info_result = get_url(info_url)
Пример #9
0
def subscription_imdb(name,url):
    if os.path.isfile(SUB_IMDB_FILE):
        existing = read_from_file(SUB_IMDB_FILE)
    if os.path.isfile(SUB_FILE):
        s = read_from_file(SUB_FILE)
        show_list = s.split('\n')
        for show in show_list:
            if show != '' and not show in existing:
                dialog = xbmcgui.Dialog()
                menu_texts = []
                menu_data = []
                params = {}
                params["title"] = show
                params["view"] = "simple"
                params["count"] = "10"
                params["title_type"] = "tv_series,mini_series,tv_special"
                url = "%s%s" % ("http://www.imdb.com/search/title?", urllib.urlencode(params))
                body = open_url(url)
 	
                first_show = regex_get_all(body, '<tr class=', '</tr>')
                if len(first_show) == 565:
                    all_td = regex_get_all(first_show, '<td', '</td>')
                    imdb_id = regex_from_to(all_td[1], '/title/', '/')
                else:
                    for f in first_show:
                        all_td = regex_get_all(f, '<td', '</td>')#year_type">
                        imdb_id = regex_from_to(all_td[1], '/title/', '/')#/">
                        title = regex_from_to(all_td[1], '/">', '</a').replace("&#x27;", "'") + ' ' + regex_from_to(f, 'year_type">', '</span>')
                        menu_data.append(imdb_id)
                        menu_texts.append(title)
                    menu_id = dialog.select('Select Show', menu_texts)
                    if(menu_id < 0):
                        return (None, None)
                        dialog.close()
                    else:	
                        imdb_id = menu_data[menu_id]
                text="%s<>%s" % (show,imdb_id)
                add_to_list(text, SUB_IMDB_FILE)
            else:
                notification('My Subsciptions', 'No new shows found', '3000', iconart)
        get_subscriptions(name,url)
Пример #10
0
 def getElement(self, element):
     try:
         return regex_from_to(self.info_result, '<' + element + '>',
                              '</' + element + '>')
     except:
         return ""
Пример #11
0
 def released(self):
     try:
         n = regex_from_to(self.info_result, 'release_date":"', '",')
     except:
         n = None
     return n
Пример #12
0
 def getElement(self, element):
     try:
         return regex_from_to(self.episode_info, '<' + element + '>', '</' + element + '>')
     except:
         return ""
Пример #13
0
 def getElement(self, element):
     try:
         return regex_from_to(self.info_result, '<' + element + '>', '</' + element + '>')
     except:
         return ""
Пример #14
0
 def rating(self):
     try:
         n = regex_from_to(self.info_result, 'vote_average":', ',"')
     except:
         n = None
     return n
Пример #15
0
 def votes(self):
     try:
         n = regex_from_to(self.info_result, 'vote_count":', ',"')
     except:
         n = None
     return n
Пример #16
0
 def overview(self):
     try:
         n = regex_from_to(self.info_result, 'overview":"', '",')
     except:
         n = None
     return n
Пример #17
0
 def name(self):
     try:
         n = regex_from_to(self.info_result, 'title":"', '",')
     except:
         n = None
     return n
Пример #18
0
 def tagline(self):
     try:
         n = regex_from_to(self.info_result, 'tagline":"', '",')
     except:
         n = None
     return n
Пример #19
0
 def getElement(self, element):
     try:
         return regex_from_to(self.episode_info, '<' + element + '>',
                              '</' + element + '>')
     except:
         return ""
Пример #20
0
 def runtime(self):
     try:
         n = regex_from_to(self.info_result, 'runtime":', ',"')
     except:
         n = None
     return n