def displayFavouriteTVShows(request_obj, response_obj):
    addonContext = Container().getAddonContext()
    
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=addonContext.addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=FAV_TV_SHOWS_JSON_FILE, makeDirs=True)

    try:
        if AddonUtils.doesFileExist(filepath):
            favTVShowsJsonObj = AddonUtils.getJsonFileObj(filepath)
            if len(favTVShowsJsonObj) == 0:
                d = xbmcgui.Dialog()
                d.ok('No Favourites added yet!', 'Please use context menu on TV Show to add new favourite.', '')
    
            for tvShowName in favTVShowsJsonObj:
                tvShowInfo = favTVShowsJsonObj[tvShowName]
                item = ListItem()
                item.add_request_data('tvShowName', tvShowInfo['tvShowName'])
                item.add_request_data('tvShowUrl', tvShowInfo['tvShowUrl'])
                item.set_next_action_name('Show_Episodes')
                xbmcListItem = xbmcgui.ListItem(label=unicode(tvShowInfo['tvShowName']).encode("utf-8"))
                
                contextMenuItems = []
                data = '?actionId=' + urllib.quote_plus("remove_Fav_TVShow") + '&data=' + urllib.quote_plus(AddonUtils.encodeData({"tvShowName":tvShowInfo['tvShowName'], "tvShowUrl":tvShowInfo['tvShowUrl']}))
                contextMenuItems.append(('Remove favourite', 'XBMC.RunPlugin(%s?%s)' % (sys.argv[0], data)))
                xbmcListItem.addContextMenuItems(contextMenuItems, replaceItems=True)
                item.set_xbmc_list_item_obj(xbmcListItem)
                response_obj.addListItem(item)
        else:
            d = xbmcgui.Dialog()
            d.ok('No favourites added yet!', 'Please use context menu on TV Show to add new favourite.', '')
        
    except:
        AddonUtils.deleteFile(filepath)
        d = xbmcgui.Dialog()
        d.ok('FAILED to display TV Shows', 'Please add favorite again.')
Exemple #2
0
def removeChannel(request_obj, response_obj):
    channelName = request_obj.get_data()['userId']
    d = xbmcgui.Dialog()
    if not d.yesno('Remove Channel : [B]' + channelName + '[/B]', 'Do you want to continue?', 'Note: This action will not delete channel from YouTube.'):
        return
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=Container().getAddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=True)
    if AddonUtils.doesFileExist(filepath):
        try:
            channelsJsonObj = AddonUtils.getJsonFileObj(filepath)
            try:
                del channelsJsonObj[channelName]
                print 'CHANNEL DELETED = ' + channelName
                AddonUtils.saveObjToJsonFile(filepath, channelsJsonObj)
                d = xbmcgui.Dialog()
                d.ok('Channel removed SUCCESSFULLY', 'You can add this channel again using same way.', 'ENJOY!')
                xbmc.executebuiltin("Container.Refresh()")
            except KeyError:
                d = xbmcgui.Dialog()
                d.ok('FAILED to remove channel', 'Please try again.')
                
        except ValueError:
            AddonUtils.deleteFile(filepath)
            print 'MY CHANNELS CORRUPT FILE DELETED = ' + filepath
    else:
        d = xbmcgui.Dialog()
        d.ok('NO channels added yet', 'Add new channel using YouTube username.', 'Get username from YouTube URL.')
Exemple #3
0
 def loadTurtleMap(self):
     turtle_filepath = AddonUtils.getCompleteFilePath(
         self.addonPath, 'config', 'turtle.xml')
     if not AddonUtils.doesFileExist(turtle_filepath):
         turtle_filepath = AddonUtils.getCompleteFilePath(
             self.turtle_addonPath, 'lib/config', 'turtle.xml')
     return AddonUtils.getBeautifulSoupObj(turtle_filepath)
Exemple #4
0
def addYeahLiveItem(request_obj, response_obj):
    yeahfilepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=False)
    if AddonUtils.doesFileExist(yeahfilepath):
        yeah_icon_filepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename='YEAH.png')
        item = ListItem()
        item.set_next_action_name('Yeah_TV')
        xbmcListItem = xbmcgui.ListItem(label='[B]YEAH[/B] STREAMS', iconImage=yeah_icon_filepath, thumbnailImage=yeah_icon_filepath)
        item.set_xbmc_list_item_obj(xbmcListItem)
        response_obj.addListItem(item)
def selectChannelsCategory(request_obj, response_obj):
    Container().ga_client.reportAction('live_FREE')
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=Container().getAddonContext().addonPath, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE)
    freeChannels = AddonUtils.getJsonFileObj(filepath)
    
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=Container().getAddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename='M.json')
    if AddonUtils.doesFileExist(filepath):
        freeChannels.update(AddonUtils.getJsonFileObj(filepath))
    request_obj.set_data({'channels': freeChannels})
Exemple #6
0
def __checkAndLoadCookieStore__(cookieStore):
    relogin = False
    if AddonUtils.doesFileExist(cookieStore):
        HttpUtils.HttpClient().loadCookiesFromFile(cookieStore)
        HttpUtils.HttpClient().enableCookies()
        html = HttpUtils.HttpClient().getHtmlContent("http://www.youtube.com/")
        if len(re.compile('My channel').findall(html)) == 0:
            relogin = True
    else:
        relogin = True
    return relogin
Exemple #7
0
def __checkAndLoadCookieStore__(cookieStore):
    relogin = False
    if AddonUtils.doesFileExist(cookieStore):
        HttpUtils.HttpClient().loadCookiesToFile(cookieStore)
        now = time.time()
        for cookie in HttpUtils.HttpClient().get_cookiejar():
            if (cookie.name == "CXUserId" or cookie.name == "CXUserName") and cookie.is_expired(now):
                relogin = True
    else:
        relogin = True
    return relogin
Exemple #8
0
def __initializeSnappers():
    snapper_filepath = AddonUtils.getCompleteFilePath(Container().getAddonContext().addonPath, 'snapvideo', 'snappers.xml')
    if not AddonUtils.doesFileExist(snapper_filepath):
        snapper_filepath = AddonUtils.getCompleteFilePath(Container().getAddonContext().turtle_addonPath, 'lib/snapvideo', 'snappers.xml')
    global snappers
    if snappers is not None:
        return snappers
    snappers = []
    Logger.logDebug('Loading snappers.xml from path... ' + snapper_filepath)
    snappers_xml = AddonUtils.getBeautifulSoupObj(snapper_filepath)
    for snapperTag in snappers_xml.findAll('snapper', attrs={'enabled':'true'}):
        snappers.append(Snapper(snapperTag))
    return snappers
def addFavouriteTVShow(request_obj, response_obj):
    addonContext = Container().getAddonContext()
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=addonContext.addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=FAV_TV_SHOWS_JSON_FILE, makeDirs=True)
    favTVShowsJsonObj = {}
    if AddonUtils.doesFileExist(filepath):
        try:
            favTVShowsJsonObj = AddonUtils.getJsonFileObj(filepath)
        except ValueError:
            AddonUtils.deleteFile(filepath)
            Logger.logError('CORRUPT FILE DELETED = ' + filepath)
    favTVShowsJsonObj[request_obj.get_data()['tvShowName']] = {"tvShowName":request_obj.get_data()['tvShowName'] , "tvShowUrl": request_obj.get_data()['tvShowUrl']}
    AddonUtils.saveObjToJsonFile(filepath, favTVShowsJsonObj)
    d = xbmcgui.Dialog()
    d.ok('TV Show favourite added successfully.', 'ENJOY!')
Exemple #10
0
def displayChannels(request_obj, response_obj):
    addonContext = Container().getAddonContext()
    item = ListItem()
    item.set_next_action_name('add_Channel')
    youtube_icon_filepath = AddonUtils.getCompleteFilePath(baseDirPath=addonContext.addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename='Add_New_YouTube_V1.png')
    xbmcListItem = xbmcgui.ListItem(label='Add New Channel', iconImage=youtube_icon_filepath, thumbnailImage=youtube_icon_filepath)
    item.set_xbmc_list_item_obj(xbmcListItem)
    response_obj.addListItem(item)   
                
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=addonContext.addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=True)
    if not AddonUtils.doesFileExist(filepath):
        new_items = XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__retrieveYouTubeUserInfo__'), PRE_LOADED_CHANNELS, 'Loading default list of channels...', 'Remove the channel you hate in default list using context menu.')
        index = 0
        channelsJsonObj = {}
        for username in PRE_LOADED_CHANNELS:
            channelsJsonObj[username] = new_items[index]
            index = index + 1
        AddonUtils.saveObjToJsonFile(filepath, channelsJsonObj)

    try:
        channelsJsonObj = AddonUtils.getJsonFileObj(filepath)
        print 'CHANNELS JSON LOADED'
        if len(channelsJsonObj) == 0:
            d = xbmcgui.Dialog()
            if d.yesno('NO channels added yet!', 'Would you like to add YouTube channel right now?', 'Get username from YouTube URL.'):
                isAdded = addNewChannel(request_obj, response_obj)
                if not isAdded:
                    return
                else:
                    channelsJsonObj = AddonUtils.getJsonFileObj(filepath)

        for channelUsername in channelsJsonObj:
            userInfo = channelsJsonObj[channelUsername]
            item = ListItem()
            item.add_request_data('userId', channelUsername)
            item.set_next_action_name('show_Channel')
            xbmcListItem = xbmcgui.ListItem(label=unicode(userInfo['title']).encode("utf-8"), iconImage=userInfo['thumbnail'], thumbnailImage=userInfo['thumbnail'])
            
            contextMenuItems = []
            data = '?actionId=' + urllib.quote_plus("remove_YouTube_Channel") + '&data=' + urllib.quote_plus(AddonUtils.encodeData({"userId":channelUsername}))
            contextMenuItems.append(('Remove channel', 'XBMC.RunPlugin(%s?%s)' % (sys.argv[0], data)))
            xbmcListItem.addContextMenuItems(contextMenuItems, replaceItems=False)
            item.set_xbmc_list_item_obj(xbmcListItem)
            response_obj.addListItem(item)
        
    except:
        raise
        AddonUtils.deleteFile(filepath)
        print 'MY CHANNELS CORRUPT FILE DELETED = ' + filepath
Exemple #11
0
 def __initialize__(self, addon_id):
     
     #Addon information
     self.addon = xbmcaddon.Addon(id=addon_id)
     self.addonPath = self.addon.getAddonInfo('path')
     self.addonProfile = self.addon.getAddonInfo('profile')
     
     self.turtle_addon = xbmcaddon.Addon(id='script.module.turtle')
     self.turtle_addonPath = self.turtle_addon.getAddonInfo('path')
     self.turtle_addonProfile = self.turtle_addon.getAddonInfo('profile')
     
     turtle_filepath = AddonUtils.getCompleteFilePath(self.addonPath, 'config', 'turtle.xml')
     if not AddonUtils.doesFileExist(turtle_filepath):
         turtle_filepath = AddonUtils.getCompleteFilePath(self.turtle_addonPath, 'lib/config', 'turtle.xml')
     self.turtle_map = AddonUtils.getBeautifulSoupObj(turtle_filepath)
def removeFavouriteTVShow(request_obj, response_obj):
    addonContext = Container().getAddonContext()
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=addonContext.addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=FAV_TV_SHOWS_JSON_FILE, makeDirs=True)
    favTVShowsJsonObj = {}
    if AddonUtils.doesFileExist(filepath):
        try:
            favTVShowsJsonObj = AddonUtils.getJsonFileObj(filepath)
            del favTVShowsJsonObj[request_obj.get_data()['tvShowName']]
            AddonUtils.saveObjToJsonFile(filepath, favTVShowsJsonObj)
            d = xbmcgui.Dialog()
            d.ok('TV Show removed favourite successfully.', 'You can add this TV Show again using same way.', 'ENJOY!')
            xbmc.executebuiltin("Container.Refresh()")
        except ValueError:
            AddonUtils.deleteFile(filepath)
            Logger.logError('CORRUPT FILE DELETED = ' + filepath)
            d = xbmcgui.Dialog()
            d.ok('Failed to remove TV Show favourite.', 'Please try again.')
Exemple #13
0
def addNewChannel(request_obj, response_obj):
    keyb = xbmc.Keyboard('', 'Enter [B]YouTube[/B] username')
    keyb.doModal()
    if (keyb.isConfirmed()):
        username = keyb.getText()
        if username == None or username == '':
            d = xbmcgui.Dialog()
            d.ok('Username not entered', 'Please enter the YouTube username correctly.', 'Get username from YouTube URL.')
        else:
            try:
                channelsJsonObj = {}
                filepath = AddonUtils.getCompleteFilePath(baseDirPath=Container().getAddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=True)
                if AddonUtils.doesFileExist(filepath):
                    try:
                        channelsJsonObj = AddonUtils.getJsonFileObj(filepath)
                        print 'CHANNELS JSON LOADED'
                    except ValueError:
                        AddonUtils.deleteFile(filepath)
                        print 'CORRUPT FILE DELETED = ' + filepath
                                
                try:
                    if channelsJsonObj[username] != None:
                        d = xbmcgui.Dialog()
                        d.ok('Channel already exists', 'Please enter the YouTube username correctly.', 'Get username from YouTube URL.')
                        
                except KeyError:
                    print 'Search for YouTube username now = ' + username
                        
                userInfo = YouTubeBrowser.retrieveYouTubeUserInfo(username)
                if userInfo != None:
                    channelsJsonObj[username] = userInfo
                    AddonUtils.saveObjToJsonFile(filepath, channelsJsonObj)
                    d = xbmcgui.Dialog()
                    d.ok('Channel added SUCCESSFULLY', 'ENJOY!')
                    xbmc.executebuiltin("Container.Refresh()")
            except urllib2.HTTPError:
                d = xbmcgui.Dialog()
                d.ok('Username doesn\'t exist', 'Please enter the YouTube username correctly.', 'Get username from YouTube URL.')
 def loadTurtleMap(self):
     turtle_filepath = AddonUtils.getCompleteFilePath(self.addonPath, 'config', 'turtle.xml')
     if not AddonUtils.doesFileExist(turtle_filepath):
         turtle_filepath = AddonUtils.getCompleteFilePath(self.turtle_addonPath, 'lib/config', 'turtle.xml')
     return AddonUtils.getBeautifulSoupObj(turtle_filepath)