Ejemplo n.º 1
0
 def add_item_to_db(self, title, fmtd_title, url, section_title, section_addon_title, sub_section_title, sub_section_addon_title, infolabels, img, fanart, is_playable, is_folder):
     if url.find('&favorite=true'):
         url = url.replace('&favorite=true', '')
     elif url.find('?favorite=true&'):
         url = url.replace('?favorite=true&', '?')
         
     hash_title = hashlib.md5(title).hexdigest()
                    
     sql_insert = ''
     if self.is_already_in_favorites(section_title, section_addon_title, sub_section_title, sub_section_addon_title, title) == True:
         #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + ' - already exists in Favorites.', '8000')
         common.notify(self.addon_id, 'small', '[B]' + fmtd_title + '[/B]', '[B]Already exists in Favorites.[/B]', '8000')
     else:
         if DB == 'mysql':
             sql_insert = "INSERT INTO favorites(addon_id, hash_title, title, fmtd_title, url, section_title, section_addon_title, sub_section_title, sub_section_addon_title, infolabels, image_url, fanart_url, isfolder, isplayable ) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
         else:
             sql_insert = "INSERT INTO favorites(addon_id, hash_title, title, fmtd_title, url, section_title, section_addon_title, sub_section_title, sub_section_addon_title, infolabels, image_url, fanart_url, isfolder, isplayable ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"            
             
         if infolabels:
             infolabels = common.encode_dict(infolabels)
             
         common.addon.log('-' + HELPER + '- -' +'%s: %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s' % (sql_insert, self.addon_id, hash_title, title, fmtd_title, url, section_title, section_addon_title, sub_section_title, sub_section_addon_title, str(infolabels), img, fanart, common.bool2str(is_folder), common.bool2str(is_playable)), 2)
         
         try:
             self.dbcur.execute(sql_insert, (self.addon_id, hash_title, title, fmtd_title, url, section_title, section_addon_title, sub_section_title, sub_section_addon_title, str(infolabels), img, fanart, common.bool2str(is_folder), common.bool2str(is_playable) ))            
             self.dbcon.commit()
             #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + ' - added successfully to Favorites.', '8000')
             common.notify(self.addon_id, 'small', '[B]' + fmtd_title + '[/B]', '[B]Added to Favorites.[/B]', '8000')
         except:
             #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + ' - unable to add to Favorites.', '8000')                
             common.notify(self.addon_id, 'small', '[B]' + fmtd_title + '[/B]', '[B]Unable to add to Favorites.[/B]', '8000')
             pass
Ejemplo n.º 2
0
def QueueItem(addon_id, title, url, is_resolved=False, img="", fanart="", infolabels=""):
    script_path = os.path.join(common.addon.get_path(), "lib", "universal", "playbackengine.py")
    pbe_infolabels = ""
    if infolabels:
        pbe_infolabels = str(common.encode_dict(infolabels))

    item_url = url
    if is_resolved == False:
        item_url = item_url + "&queued=true"

    pbe_params = {
        "pbe_mode": "queueitem",
        "pbe_addon_id": addon_id,
        "pbe_title": title,
        "pbe_url": item_url,
        "pbe_img": img,
        "pbe_fanart": fanart,
        "pbe_infolabels": pbe_infolabels,
    }
    pbe_script = 'XBMC.RunScript(%s, %s, %s, "%s")' % (
        script_path,
        sys.argv[1],
        "?" + common.dict_to_paramstr(pbe_params),
        "script.module.universal.playbackengine",
    )

    return pbe_script
Ejemplo n.º 3
0
    def add_item_to_db(self, title, fmtd_title, url, section_title,
                       section_addon_title, sub_section_title,
                       sub_section_addon_title, infolabels, img, fanart,
                       is_playable, is_folder):
        if url.find('&favorite=true'):
            url = url.replace('&favorite=true', '')
        elif url.find('?favorite=true&'):
            url = url.replace('?favorite=true&', '?')

        hash_title = hashlib.md5(title).hexdigest()

        sql_insert = ''
        if self.is_already_in_favorites(section_title, section_addon_title,
                                        sub_section_title,
                                        sub_section_addon_title,
                                        title) == True:
            #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + ' - already exists in Favorites.', '8000')
            common.notify(self.addon_id, 'small', '[B]' + fmtd_title + '[/B]',
                          '[B]Already exists in Favorites.[/B]', '8000')
        else:
            if DB == 'mysql':
                sql_insert = "INSERT INTO favorites(addon_id, hash_title, title, fmtd_title, url, section_title, section_addon_title, sub_section_title, sub_section_addon_title, infolabels, image_url, fanart_url, isfolder, isplayable ) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
            else:
                sql_insert = "INSERT INTO favorites(addon_id, hash_title, title, fmtd_title, url, section_title, section_addon_title, sub_section_title, sub_section_addon_title, infolabels, image_url, fanart_url, isfolder, isplayable ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

            if infolabels:
                infolabels = common.encode_dict(infolabels)

            common.addon.log(
                '-' + HELPER + '- -' +
                '%s: %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s' %
                (sql_insert, self.addon_id, hash_title, title, fmtd_title, url,
                 section_title, section_addon_title, sub_section_title,
                 sub_section_addon_title, str(infolabels), img, fanart,
                 common.bool2str(is_folder), common.bool2str(is_playable)), 2)

            try:
                self.dbcur.execute(
                    sql_insert,
                    (self.addon_id, hash_title, title, fmtd_title, url,
                     section_title, section_addon_title, sub_section_title,
                     sub_section_addon_title, str(infolabels), img, fanart,
                     common.bool2str(is_folder), common.bool2str(is_playable)))
                self.dbcon.commit()
                #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + ' - added successfully to Favorites.', '8000')
                common.notify(self.addon_id, 'small',
                              '[B]' + fmtd_title + '[/B]',
                              '[B]Added to Favorites.[/B]', '8000')
            except:
                #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + ' - unable to add to Favorites.', '8000')
                common.notify(self.addon_id, 'small',
                              '[B]' + fmtd_title + '[/B]',
                              '[B]Unable to add to Favorites.[/B]', '8000')
                pass
Ejemplo n.º 4
0
def QueueItem(addon_id, title, url, is_resolved=False,img='', fanart='', infolabels=''):
    script_path = os.path.join(common.addon.get_path(), 'lib', 'universal', 'playbackengine.py')
    pbe_infolabels = ''
    if infolabels:
        pbe_infolabels = str(common.encode_dict(infolabels))
    
    item_url = url
    if is_resolved == False:
        item_url = item_url + '&queued=true'
    
    pbe_params = {
        'pbe_mode' : 'queueitem',
        'pbe_addon_id': addon_id,
        'pbe_title' : title,
        'pbe_url' : item_url,
        'pbe_img' : img,
        'pbe_fanart' : fanart,
        'pbe_infolabels' : pbe_infolabels
    }
    pbe_script = 'XBMC.RunScript(%s, %s, %s, "%s")' % (script_path, sys.argv[1], '?' + common.dict_to_paramstr(pbe_params), 'script.module.universal.playbackengine')
    
    return pbe_script
Ejemplo n.º 5
0
def QueueItem(addon_id, title, url, is_resolved=False,img='', fanart='', infolabels=''):
    script_path = os.path.join(common.addon.get_path(), 'lib', 'universal', 'playbackengine.py')
    pbe_infolabels = ''
    if infolabels:
        pbe_infolabels = str(common.encode_dict(infolabels))
    
    item_url = url
    if is_resolved == False:
        item_url = item_url + '&queued=true'
    
    pbe_params = {
        'pbe_mode' : 'queueitem',
        'pbe_addon_id': addon_id,
        'pbe_title' : title,
        'pbe_url' : item_url,
        'pbe_img' : img,
        'pbe_fanart' : fanart,
        'pbe_infolabels' : pbe_infolabels
    }
    pbe_script = 'XBMC.RunScript(%s, %s, %s, "%s")' % (script_path, sys.argv[1], '?' + common.dict_to_paramstr(pbe_params), 'script.module.universal.playbackengine')
    
    return pbe_script
Ejemplo n.º 6
0
    def add_item(self,
                 title,
                 url,
                 fmtd_title='',
                 level='0',
                 parent_title='',
                 indent_title='',
                 infolabels='',
                 img='',
                 fanart='',
                 is_playable=False,
                 is_folder=False):
        '''
            Add an item to watch history.
            
            Args:
                title (str): title of the item; used to generate title-hash and sorting
                
                url (str): the compelte plugin url that would be called when this item is selected
                
            Kwargs:
                fmtd_title (str): title of the item as it will be displayed in the list. 
                        if fmtd_title is None:
                            fmtd_title = title
                            
                level (str): item level in the hierarchy. Used if playable-item's parent is also being added to the favorites.
                        Non-parent's level is '0'
                        Parent's level starts with '1'
                        Should be covnertiable to integer
                        
                parent_title (str): If the item has a parent, then the title used to identify the parent
                
                indent_title (str): Title to be used in parent-indent mode (WIP)
                        If indent_title is None:
                            indent_title = fmtd_title
                            
                info_labels (hash): Any information that the calling plugin might need when the item is being retreived goes here.
                        This is also used to set support for metadata for the item with watch history.
                        infolabels = { 'supports_meta' : 'true', 'video_type':video_type, 'name':title, 'imdb_id':imdb_id, 
                            'season':season, 'episode':episode, 'year':year 
                        }
                        
                img (str): url or path of the image to be used as thumbnail and icon of the item
                
                fanart (str): url or path of the image to be used as fanart of the item
                
                is_playable (bool): set the item isPlayable property
                
                is_folder (bool): set the item isFolder property
        '''
        if url.find('&watchhistory=true'):
            url = url.replace('&watchhistory=true', '')
        elif url.find('?watchhistory=true&'):
            url = url.replace('?watchhistory=true&', '?')

        title = common.str_conv(title)

        if not fmtd_title:
            fmtd_title = title
        else:
            fmtd_title = common.str_conv(fmtd_title)

        if not indent_title:
            indent_title = fmtd_title
        else:
            indent_title = common.str_conv(indent_title)

        hash_title = hashlib.md5(title).hexdigest()

        if parent_title:
            parent_title = common.str_conv(parent_title)

        if parent_title:
            parent_title = hashlib.md5(parent_title).hexdigest()

        row_exists = True
        try:
            if DB == 'mysql':
                sql_select = "SELECT * FROM watch_history WHERE addon_id = %s AND hash_title = %s"
            else:
                sql_select = "SELECT * FROM watch_history WHERE addon_id = ? AND hash_title = ?"
            common.addon.log(
                '-' + HELPER + '- -' + '%s : %s, %s' %
                (sql_select, self.addon_id, hash_title), 2)
            self.dbcur.execute(sql_select, (self.addon_id, hash_title))
            common.addon.log(
                '-' + HELPER + '- -' + str(self.dbcur.fetchall()[0]), 2)
        except:
            row_exists = False

        sql_update_or_insert = ''
        if row_exists == True:
            if DB == 'mysql':
                sql_update_or_insert = "UPDATE watch_history SET lastwatched = %s WHERE addon_id = %s AND hash_title = %s"
            else:
                sql_update_or_insert = "UPDATE watch_history SET lastwatched = ? WHERE addon_id = ? AND hash_title = ?"
            common.addon.log(
                '-' + HELPER + '- -' + '%s : %s, %s, %s' %
                (sql_update_or_insert, 'datetime.datetime.now()',
                 self.addon_id, hash_title), 2)
            self.dbcur.execute(
                sql_update_or_insert,
                (datetime.datetime.now(), self.addon_id, hash_title))
        else:
            if DB == 'mysql':
                sql_update_or_insert = "INSERT INTO watch_history(addon_id, hash_title, title, fmtd_title, url, infolabels, image_url, fanart_url, isplayable, isfolder, lastwatched, level, parent_title, indent_title) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
            else:
                sql_update_or_insert = "INSERT INTO watch_history(addon_id, hash_title, title, fmtd_title, url, infolabels, image_url, fanart_url, isplayable, isfolder, lastwatched, level, parent_title, indent_title) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

            if infolabels:
                infolabels = common.encode_dict(infolabels)

            is_playable = common.bool2str(is_playable)
            is_folder = common.bool2str(is_folder)
            infolabels = str(infolabels)

            common.addon.log(
                '-' + HELPER + '- -' +
                '%s : %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s' %
                (sql_update_or_insert, self.addon_id, hash_title, title,
                 fmtd_title, common.str_conv(url), infolabels, img, fanart,
                 is_playable, is_folder, 'datetime.datetime.now()', level,
                 parent_title, indent_title), 2)
            self.dbcur.execute(
                sql_update_or_insert,
                (self.addon_id, hash_title, title, fmtd_title, url,
                 infolabels, img, fanart, is_playable, is_folder,
                 datetime.datetime.now(), level, parent_title, indent_title))
        self.dbcon.commit()
Ejemplo n.º 7
0
    def add_item(self, title, url, fmtd_title = '', level='0', parent_title='', indent_title='', infolabels='', img='', fanart='', is_playable=False, is_folder=False):
        '''
            Add an item to watch history.
            
            Args:
                title (str): title of the item; used to generate title-hash and sorting
                
                url (str): the compelte plugin url that would be called when this item is selected
                
            Kwargs:
                fmtd_title (str): title of the item as it will be displayed in the list. 
                        if fmtd_title is None:
                            fmtd_title = title
                            
                level (str): item level in the hierarchy. Used if playable-item's parent is also being added to the favorites.
                        Non-parent's level is '0'
                        Parent's level starts with '1'
                        Should be covnertiable to integer
                        
                parent_title (str): If the item has a parent, then the title used to identify the parent
                
                indent_title (str): Title to be used in parent-indent mode (WIP)
                        If indent_title is None:
                            indent_title = fmtd_title
                            
                info_labels (hash): Any information that the calling plugin might need when the item is being retreived goes here.
                        This is also used to set support for metadata for the item with watch history.
                        infolabels = { 'supports_meta' : 'true', 'video_type':video_type, 'name':title, 'imdb_id':imdb_id, 
                            'season':season, 'episode':episode, 'year':year 
                        }
                        
                img (str): url or path of the image to be used as thumbnail and icon of the item
                
                fanart (str): url or path of the image to be used as fanart of the item
                
                is_playable (bool): set the item isPlayable property
                
                is_folder (bool): set the item isFolder property
        '''
        if url.find('&watchhistory=true'):
            url = url.replace('&watchhistory=true', '')
        elif url.find('?watchhistory=true&'):
            url = url.replace('?watchhistory=true&', '?')
            
        title = common.str_conv(title)                
            
        if not fmtd_title:
            fmtd_title = title
        else:
            fmtd_title = common.str_conv(fmtd_title)
            
        if not indent_title:
            indent_title = fmtd_title
        else:
            indent_title = common.str_conv(indent_title)
            
        hash_title = hashlib.md5(title).hexdigest()

        if parent_title:
            parent_title = common.str_conv(parent_title)

        if parent_title:
            parent_title = hashlib.md5(parent_title).hexdigest()
                       
        row_exists = True
        try:
            if DB == 'mysql':
                sql_select = "SELECT * FROM watch_history WHERE addon_id = %s AND hash_title = %s"
            else:
                sql_select = "SELECT * FROM watch_history WHERE addon_id = ? AND hash_title = ?"
            common.addon.log('-' + HELPER + '- -' + '%s : %s, %s' %(sql_select, self.addon_id, hash_title), 2 )
            self.dbcur.execute(sql_select, (self.addon_id, hash_title))
            common.addon.log('-' + HELPER + '- -' + str(self.dbcur.fetchall()[0]), 2)
        except:
            row_exists = False
                
        sql_update_or_insert = ''
        if row_exists == True:
            if DB == 'mysql':
                sql_update_or_insert = "UPDATE watch_history SET lastwatched = %s WHERE addon_id = %s AND hash_title = %s" 
            else:
                sql_update_or_insert = "UPDATE watch_history SET lastwatched = ? WHERE addon_id = ? AND hash_title = ?" 
            common.addon.log('-' + HELPER + '- -' + '%s : %s, %s, %s' %(sql_update_or_insert, 'datetime.datetime.now()', self.addon_id, hash_title), 2 )
            self.dbcur.execute(sql_update_or_insert, (datetime.datetime.now(), self.addon_id, hash_title))
        else:        
            if DB == 'mysql':
                sql_update_or_insert = "INSERT INTO watch_history(addon_id, hash_title, title, fmtd_title, url, infolabels, image_url, fanart_url, isplayable, isfolder, lastwatched, level, parent_title, indent_title) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
            else:
                sql_update_or_insert = "INSERT INTO watch_history(addon_id, hash_title, title, fmtd_title, url, infolabels, image_url, fanart_url, isplayable, isfolder, lastwatched, level, parent_title, indent_title) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
                
            if infolabels:
                infolabels = common.encode_dict(infolabels)
                
            is_playable = common.bool2str(is_playable)
            is_folder = common.bool2str(is_folder)
            infolabels = str(infolabels)
            
            common.addon.log('-' + HELPER + '- -' + '%s : %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s' %(sql_update_or_insert, self.addon_id, hash_title, title, fmtd_title, common.str_conv(url), infolabels, img, fanart, is_playable, is_folder, 'datetime.datetime.now()', level, parent_title, indent_title), 2 )
            self.dbcur.execute(sql_update_or_insert, (self.addon_id, hash_title, title, fmtd_title, url, infolabels, img, fanart, is_playable, is_folder, datetime.datetime.now(), level, parent_title, indent_title))
        self.dbcon.commit()