Exemple #1
0
 def __init__(self, url, cache_time):
     path = _get_path('cache')
     file = md5.new(url).hexdigest()
     file += '.rss'
     
     self.cache_path = os.path.join(path, file)
     self.feed = url
     self.cache_time = cache_time
    def _get_cookie(self, check_file=True):
        cookie_data = None
        cookie_path = _get_path('newzbin_cookie2.txt')

        if check_file and os.access(cookie_path, os.F_OK):
            f = open(cookie_path, 'rb')
            cookie_data = f.read()
            f.close()

        if not cookie_data:
            print 'sabnzbd-xbmc existing cookie not found, requesting new one'
            cookie_data = self._fetch_cookie(username_newzbin, password_newzbin)
            f = open(cookie_path, 'wb')
            f.write(cookie_data)
            f.close()
        else:
            print 'sabnzbd-xbmc existing cookie found!'
        return cookie_data
Exemple #3
0
    def _get_cookie(self, check_file=True):
        cookie_data = None
        cookie_path = _get_path('newzbin_cookie2.txt')

        if check_file and os.access(cookie_path, os.F_OK):
            f = open(cookie_path, 'rb')
            cookie_data = f.read()
            f.close()

        if not cookie_data:
            print 'sabnzbd-xbmc existing cookie not found, requesting new one'
            cookie_data = self._fetch_cookie(username_newzbin,
                                             password_newzbin)
            f = open(cookie_path, 'wb')
            f.write(cookie_data)
            f.close()
        else:
            print 'sabnzbd-xbmc existing cookie found!'
        return cookie_data
Exemple #4
0
    def _fill_list(self, items):
        '''
        Generate and show listitems for xbmc from generated the dictionary
        '''
        try:
            ok = False
            print 'sabnzbd-xbmc Filling the list'
            # enumerate through the list of categories and add the item to the media list
            print 'sabnzbd-xbmc total items found: %s' % len(items["assets"])
            for item in items["assets"]:
                info = {}
                #if the expected output are folders (does not support a mixed folder/file view)
                if items['folder']:
                    heading = "rss_url"
                    thumbnail = ""
                    isFolder = True
                    item['id'] = ''
                elif item['type'] == 'nzb_dl':
                    heading = "download_nzb"
                    thumbnail = _get_path('sabc_64.png')
                    isFolder = False
                else:
                    heading = "sabnzbd_action"
                    isFolder = False
                    thumbnail = ''

                if 'sabnzbd' in item["name"].lower():
                    icon = thumbnail = _get_path('default.tbn')

                elif item.has_key('imdb') and item['imdb'] and \
                     (self.settings[ "imdb_info_fetch" ] or self.settings[ "imdb_poster_fetch" ]):
                    imdb = 'http://akas.imdb.com/title/%s/' % item['imdb']
                    info = self.IMDbFetcher.fetch_info(
                        imdb, self.settings["poster_size"], fetch_poster=False)
                    if info and info.poster_url and self.settings[
                            "imdb_poster_fetch"]:
                        icon = thumbnail = info.poster_url
                        print 'icon and thumnail set to: %s' % info.poster_url
                    else:
                        print 'no poster, using sabc_64.png'
                        icon = thumbnail = ''

                    if self.settings["imdb_poster_fetch"] and not self.settings[
                            "imdb_info_fetch"]:
                        info = {}

                elif item["name"].lower().startswith('newzbin'):
                    icon = thumbnail = _get_path('newzbin.png')
                elif isFolder == False:
                    icon = thumbnail = _get_path('sabc_64.png')
                else:
                    icon = "DefaultFolder.png"
                    thumbnail = ""

                cookie = check_attribute(self.args, 'cookie', 'default')
                cat = check_dict_key(item, 'category', 'default')

                try:
                    print u'%s - %s - %s' % (item["name"], thumbnail, cat)
                except:
                    pass

                url = '%s?%s="""%s!?!%s!?!%s!?!%s""",cookie="""%s""",old_handle="%s"' % (
                    sys.argv[0], heading, item["url"], item["name"],
                    item["id"], cat, cookie, sys.argv[1])
                # set the default icon
                #icon = "DefaultFolder.png"
                title = item['name'].replace("%20", " ").title()
                title = title.replace('\'S', '\'s').replace('Iii',
                                                            'III').replace(
                                                                'Ii', 'II')
                title_quoted_match = re.search("\"(.+?)\"", title)
                if title_quoted_match:
                    title = title_quoted_match.group(1)
                listitem = xbmcgui.ListItem(title,
                                            label2='hi',
                                            iconImage=icon,
                                            thumbnailImage=thumbnail)
                if not info:
                    icon = "DefaultFolder.png"
                    listitem.setInfo(type="Video", infoLabels={"Title": title})
                else:
                    #listitem.setThumbnailImage(info.poster)
                    listitem.setInfo(type="Video",
                                     infoLabels={
                                         "Title": title,
                                         "Overlay": xbmcgui.ICON_OVERLAY_HD,
                                         "Plot": info.plot,
                                         "Duration": info.duration,
                                         "MPAA": info.mpaa,
                                         "Genre": info.genre,
                                         "Director": info.director,
                                         "Writer": info.writer,
                                         "Studio": info.studio,
                                         "Year": info.year,
                                         "Rating": info.user_rating,
                                         "Votes": info.user_votes,
                                         "Tagline": info.tagline,
                                         "Cast": info.cast
                                     })
                    listitem.setLabel2('hi')
                    listitem.setProperty('label3', 'hi')
                    print 'findme: %s' % listitem.getLabel2()
                    xbmcplugin.setContent(handle=int(sys.argv[1]),
                                          content="movies")

                # add the item to the media list
                ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                 url=url,
                                                 listitem=listitem,
                                                 isFolder=isFolder,
                                                 totalItems=len(
                                                     items["assets"]))
                # if user cancels, call raise to exit loop
                if (not ok): raise
        except:
            # user cancelled dialog or an error occurred
            print "ERROR: %s::%s (%d) - %s" % (
                self.__class__.__name__,
                sys.exc_info()[2].tb_frame.f_code.co_name,
                sys.exc_info()[2].tb_lineno,
                sys.exc_info()[1],
            )
            ok = False
        if (ok):
            xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                     sortMethod=xbmcplugin.SORT_METHOD_NONE)
        return ok
Exemple #5
0
    def _fill_list( self, items ):
        '''
        Generate and show listitems for xbmc from generated the dictionary
        '''
        try:
            ok = False
            print 'sabnzbd-xbmc Filling the list'
            # enumerate through the list of categories and add the item to the media list
            print 'sabnzbd-xbmc total items found: %s' % len(items["assets"])
            for item in items[ "assets" ]:
                info = {}
                #if the expected output are folders (does not support a mixed folder/file view)
                if items['folder']:
                    heading = "rss_url"
                    thumbnail = ""
                    isFolder = True
                    item['id'] = ''
                elif item['type'] == 'nzb_dl':
                    heading = "download_nzb"
                    thumbnail = _get_path('sabc_64.png')
                    isFolder = False
                else:
                    heading = "sabnzbd_action"
                    isFolder = False
                    thumbnail = ''

                if 'sabnzbd' in item["name"].lower():
                    icon = thumbnail = _get_path('default.tbn')

                elif item.has_key('imdb') and item['imdb'] and \
                     (self.settings[ "imdb_info_fetch" ] or self.settings[ "imdb_poster_fetch" ]):
                    imdb = 'http://akas.imdb.com/title/%s/' % item['imdb']
                    info = self.IMDbFetcher.fetch_info( imdb, self.settings[ "poster_size" ] , fetch_poster=False)
                    if info and info.poster_url and self.settings[ "imdb_poster_fetch" ]:
                        icon = thumbnail = info.poster_url
                        print 'icon and thumnail set to: %s' % info.poster_url
                    else:
                        print 'no poster, using sabc_64.png'
                        icon = thumbnail = ''

                    if self.settings[ "imdb_poster_fetch" ] and not self.settings[ "imdb_info_fetch" ]:
                        info = {}

                elif item["name"].lower().startswith('newzbin'):
                    icon = thumbnail = _get_path('newzbin.png')
                elif isFolder == False:
                    icon = thumbnail = _get_path('sabc_64.png')
                else:
                    icon = "DefaultFolder.png"
                    thumbnail =  ""

                cookie = check_attribute(self.args, 'cookie', 'default')
                cat = check_dict_key(item, 'category', 'default')

                try:
                    print u'%s - %s - %s' % (item["name"], thumbnail, cat)
                except:
                    pass

                url = '%s?%s="""%s!?!%s!?!%s!?!%s""",cookie="""%s""",old_handle="%s"' % ( sys.argv[ 0 ], heading, item["url"], item["name"], item["id"], cat, cookie, sys.argv[ 1 ] )
                # set the default icon
                #icon = "DefaultFolder.png"
                title = item['name'].replace("%20"," ").title()
                title = title.replace('\'S','\'s').replace('Iii','III').replace('Ii','II')
                title_quoted_match = re.search("\"(.+?)\"", title)
                if title_quoted_match:
                    title = title_quoted_match.group(1)
                listitem = xbmcgui.ListItem( title, label2='hi', iconImage=icon, thumbnailImage=thumbnail )
                if not info:
                    icon = "DefaultFolder.png"
                    listitem.setInfo( type="Video", infoLabels={ "Title": title} )
                else:
                    #listitem.setThumbnailImage(info.poster)
                    listitem.setInfo( type="Video", infoLabels={ "Title": title,"Overlay": xbmcgui.ICON_OVERLAY_HD,  "Plot": info.plot, "Duration": info.duration, "MPAA": info.mpaa, "Genre": info.genre, "Director": info.director, "Writer": info.writer, "Studio": info.studio, "Year": info.year, "Rating": info.user_rating, "Votes": info.user_votes, "Tagline": info.tagline, "Cast": info.cast } )
                    listitem.setLabel2('hi')
                    listitem.setProperty('label3','hi')
                    print 'findme: %s' % listitem.getLabel2()
                    xbmcplugin.setContent( handle=int( sys.argv[ 1 ] ), content="movies" )

                # add the item to the media list
                ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=isFolder, totalItems=len( items[ "assets" ] ) )
                # if user cancels, call raise to exit loop
                if ( not ok ): raise
        except:
            # user cancelled dialog or an error occurred
            print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[ 2 ].tb_frame.f_code.co_name, sys.exc_info()[ 2 ].tb_lineno, sys.exc_info()[ 1 ], )
            ok = False
        if ( ok ):
            xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
        return ok