Beispiel #1
0
 def add_my_fav_directory(self, title='Favorites', img='', fanart='', item_mode='main'):
     if not self.sys_argv:
         common.addon.log_error('-' + HELPER + '- -' +'sys.argv not passed in Favorites __init__(); Favorites directory will not be created.')
         return
         
     try:
         tmp_addon_id = 'plugin.video.favorites'
         tmp_addon = Addon(tmp_addon_id)
         tmp_addon_name = tmp_addon.get_name()                
     except:
         common.addon.log_error('-' + HELPER + '- -' +'Favorites video plugin not installed; Favorites directory will not be created.')
         common.notify(self.addon_id, 'small', ' - My Favorites video addon required', 'Please install My Favorites video addon from The ONE\'s XBMC Addons Repository.', '10000')                
         return
         
     
     listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
     listitem.setProperty('fanart_image', fanart)
     uni_fav = {
         'uni_fav_addon_id': self.addon_id,
         'uni_fav_mode': 'display',
         'uni_fav_item_mode': item_mode
         }
     
     params = self._build_params( {'mode':'browse', 'addon_id':self.addon_id, 'local':'true', 'item_mode':item_mode} )
     xbmcplugin.addDirectoryItem(handle=int(self.sys_argv[1]),url='plugin://plugin.video.favorites/'+params,isFolder=True,listitem=listitem)
Beispiel #2
0
 def delete_item_from_db(self, title, fmtd_title, section_title, section_addon_title, sub_section_title, sub_section_addon_title, item_mode='main'):
 
     hash_title = hashlib.md5(title).hexdigest()
     
     item_column_section = ''
     item_column_sub_section = ''
     if item_mode == 'main':
         item_column_section = 'section_title'
         item_column_sub_section = 'sub_section_title'
     elif item_mode == 'addon':
         item_column_section = 'section_addon_title'
         item_column_sub_section = 'sub_section_addon_title'
     
     sql_delete = ''
     if DB == 'mysql':
         sql_delete = "DELETE FROM favorites WHERE addon_id = %s AND " + item_column_section + " = %s AND " + item_column_sub_section + " = %s AND hash_title = %s"
     else:
         sql_delete = "DELETE FROM favorites WHERE addon_id = ? AND " + item_column_section + " = ? AND " + item_column_sub_section + " = ? AND hash_title = ?"
     
     common.addon.log('-' + HELPER + '- -' + '%s: %s, %s, %s, %s' % (sql_delete, self.addon_id, section_title, sub_section_title, hash_title), 2)
     
     try:
         self.dbcur.execute(sql_delete, (self.addon_id, section_title, sub_section_title, hash_title) )            
         self.dbcon.commit()
         #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + ' - removed successfully from Favorites.', '8000')
         common.notify(self.addon_id, 'small', '[B]' + fmtd_title + '[/B]', '[B]Removed from Favorites.[/B]', '8000')
     except:
         #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + ' - unable to remove from Favorites.', '8000')                
         common.notify(self.addon_id, 'small', '[B]' + fmtd_title + '[/B]', '[B]Unable to remove from Favorites.[/B]', '8000')
         pass
Beispiel #3
0
 def add_my_history_directory(self, title='Watch History', img='', fanart=''):
     if not self.sys_argv:
         common.addon.log_error('-' + HELPER + '- -' +'sys.argv not passed in WatchHistory __init__(); Watch History directory will not be created.')
         return
         
     try:
         tmp_addon_id = 'plugin.video.watchhistory'
         tmp_addon = Addon(tmp_addon_id)
         tmp_addon_name = tmp_addon.get_name()                
     except:
         common.addon.log_error('-' + HELPER + '- -' +'Watch History video plugin not installed; Watch History directory will not be created.')
         common.notify(self.addon_id, 'small', ' - Watch History video addon required', 'Please install Watch History video addon from The ONE\'s XBMC Addons Repository.', '10000')                            
         return
     
     listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
     listitem.setProperty('fanart_image', fanart)
     
     params = '?' + common.dict_to_paramstr( {'mode':'browse', 'addon_id':self.addon_id, 'local':'true'} )
     xbmcplugin.addDirectoryItem(handle=int(self.sys_argv[1]),url='plugin://plugin.video.watchhistory/'+params,isFolder=True,listitem=listitem)
Beispiel #4
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
Beispiel #5
0
    def add_my_history_directory(self,
                                 title='Watch History',
                                 img='',
                                 fanart=''):
        if not self.sys_argv:
            common.addon.log_error(
                '-' + HELPER + '- -' +
                'sys.argv not passed in WatchHistory __init__(); Watch History directory will not be created.'
            )
            return

        try:
            tmp_addon_id = 'plugin.video.watchhistory'
            tmp_addon = Addon(tmp_addon_id)
            tmp_addon_name = tmp_addon.get_name()
        except:
            common.addon.log_error(
                '-' + HELPER + '- -' +
                'Watch History video plugin not installed; Watch History directory will not be created.'
            )
            common.notify(
                self.addon_id, 'small',
                ' - Watch History video addon required',
                'Please install Watch History video addon from The ONE\'s XBMC Addons Repository.',
                '10000')
            return

        listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
        listitem.setProperty('fanart_image', fanart)

        params = '?' + common.dict_to_paramstr({
            'mode': 'browse',
            'addon_id': self.addon_id,
            'local': 'true'
        })
        xbmcplugin.addDirectoryItem(handle=int(self.sys_argv[1]),
                                    url='plugin://plugin.video.watchhistory/' +
                                    params,
                                    isFolder=True,
                                    listitem=listitem)
Beispiel #6
0
     except:
         import simplejson as json
     infolabels = json.loads(re.sub(r",\s*(\w+)", r", '\1'", re.sub(r"\{(\w+)", r"{'\1'", infolabels.replace('\\','\\\\'))).replace("'", '"'))
     infolabels = common.decode_dict(infolabels)
 
 if pbe_mode == 'queueitem':
     try:
         playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
         
         item_already_in_PL = False
         playlist_item_count = len(playlist)
         playlist_item_loop = playlist_item_count
         for x in range(0, playlist_item_loop):
             if playlist[x].getfilename() == url:
                 item_already_in_PL = True
                 common.notify(addon_id_tmp, 'small', '', 'Item: ' + title + ' - already in Queue.', '8000')
                 break
         if item_already_in_PL == False:
             
             listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
             
             if fanart:
                 listitem.setProperty('fanart_image', fanart)
 
             if infolabels:
                 listitem.setInfo("Video", infolabels)
             
             playlist.add(url=url, listitem=listitem)
             common.notify(addon_id_tmp, 'small', '', 'Item: ' + title + ' - added successfully to Queue.', '8000')
     except:
         common.notify(addon_id_tmp, 'small', '', 'Item: ' + title + ' - unable to add to Queue.', '8000')
                "'", '"'
            )
        )
        infolabels = common.decode_dict(infolabels)

    if pbe_mode == "queueitem":
        try:
            playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)

            item_already_in_PL = False
            playlist_item_count = len(playlist)
            playlist_item_loop = playlist_item_count
            for x in range(0, playlist_item_loop):
                if playlist[x].getfilename() == url:
                    item_already_in_PL = True
                    common.notify(addon_id_tmp, "small", "", "Item: " + title + " - already in Queue.", "8000")
                    break
            if item_already_in_PL == False:

                listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)

                if fanart:
                    listitem.setProperty("fanart_image", fanart)

                if infolabels:
                    listitem.setInfo("Video", infolabels)

                playlist.add(url=url, listitem=listitem)
                common.notify(addon_id_tmp, "small", "", "Item: " + title + " - added successfully to Queue.", "8000")
        except:
            common.notify(addon_id_tmp, "small", "", "Item: " + title + " - unable to add to Queue.", "8000")