Exemplo n.º 1
0
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.')
Exemplo n.º 2
0
def retrieveTVShowsAndSave(request_obj, response_obj):
    oldfilepath = AddonUtils.getCompleteFilePath(baseDirPath=Container().getAddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=OLD_CHANNELS_JSON_FILE, makeDirs=True)
    AddonUtils.deleteFile(oldfilepath)
    
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=Container().getAddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=True)
    refresh = Container().getAddonContext().addon.getSetting('dtForceRefresh')
    if refresh == None or refresh != 'true':
        lastModifiedTime = AddonUtils.getFileLastModifiedTime(filepath)
        if lastModifiedTime is not None:
            diff = long((time.time() - lastModifiedTime) / 3600)
            if diff < 720:
                return
            else:
                Logger.logDebug(CHANNELS_JSON_FILE + ' was last created 30 days ago, refreshing data.')
    else:
        Logger.logDebug(CHANNELS_JSON_FILE + ' request to forcely refresh data. ')
    
    tvChannels = {}
    __retrieveChannels__(tvChannels, BASE_WSITE_URL + '/', CHANNEL_TYPE_IND)
    __retrieveChannels__(tvChannels, BASE_WSITE_URL + '/pakistan-tv/', CHANNEL_TYPE_PAK)
    # save tvChannels in moving data
    request_obj.get_data()['tvChannels'] = tvChannels
    
    status = AddonUtils.saveObjToJsonFile(filepath, tvChannels)
    if status is not None:
        Logger.logDebug('Saved status = ' + str(status))
    Container().getAddonContext().addon.setSetting('dtForceRefresh', 'false')
Exemplo n.º 3
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.')
Exemplo n.º 4
0
def __loginAndSaveCookieStore__(cookieStore):
    AddonUtils.deleteFile(cookieStore)
    email = Container().getAddonContext().addon.getSetting("email")
    password = Container().getAddonContext().addon.getSetting("password")
    if email == None or email == "" or password == None or password == "":
        d = xbmcgui.Dialog()
        d.ok(
            "Welcome to Willow TV",
            "Watch LIVE CRICKET on your favorite Willow TV.",
            "Please provide your login details for both",
            "Willow TV and YouTube.",
        )
        Container().getAddonContext().addon.openSettings(sys.argv[0])
        return False
    params = {"Email": email, "Password": password, "KeepSigned": "true", "LoginFormSubmit": "true"}
    html = HttpUtils.HttpClient().getHtmlContent(LOGIN_URL, params)
    HttpUtils.HttpClient().saveCookiesToFile(cookieStore)
    match = re.compile("Error: Your email or password is incorrect").findall(html)
    if len(match) > 0:
        XBMCInterfaceUtils.displayDialogMessage(
            "Login Failure", "Error: Your email or password is incorrect.", "Please verify your login details."
        )
        return False
    else:
        return True
Exemplo n.º 5
0
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!')
Exemplo n.º 6
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
Exemplo n.º 7
0
def __loginAndSaveCookieStore__(cookieStore):
    AddonUtils.deleteFile(cookieStore)
    email = Container().getAddonContext().addon.getSetting('yt_email')
    password = Container().getAddonContext().addon.getSetting('yt_password')
    if email == None or email == '' or password == None or password == '':
        d = xbmcgui.Dialog()
        d.ok('Welcome to Willow TV', 'Watch LIVE CRICKET on your favorite Willow TV.', 'Please provide your login details for YouTube Account.')
        Container().getAddonContext().addon.openSettings(sys.argv[ 0 ])
        email = Container().getAddonContext().addon.getSetting('yt_email')
        password = Container().getAddonContext().addon.getSetting('yt_password')
    successInd = __loginYouTube__(LOGIN_URL, email, password)
    if successInd:
        HttpUtils.HttpClient().saveCookiesToFile(cookieStore)
    else:
        raise Exception(ExceptionHandler.DONOT_DISPLAY_ERROR);
    return successInd
Exemplo n.º 8
0
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.')
Exemplo n.º 9
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.')
Exemplo n.º 10
0
def retrieveTVShowsAndSave(request_obj, response_obj):
    oldfilepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=OLD_CHANNELS_JSON_FILE, makeDirs=True)
    AddonUtils.deleteFile(oldfilepath)
    
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=True)
    refresh = AddonContext().addon.getSetting('drForceRefresh')
    if refresh == None or refresh != 'true':
        lastModifiedTime = AddonUtils.getFileLastModifiedTime(filepath)
        if lastModifiedTime is not None:
            diff = long((time.time() - lastModifiedTime) / 3600)
            if diff < 720:
                return
            else:
                print CHANNELS_JSON_FILE + ' was last created 30 days ago, refreshing data.'
    else:
        print CHANNELS_JSON_FILE + ' request to force refresh data. '
    tvChannels = {"UTV Stars":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/uu/utv_stars.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/utv-stars/",
                   "finished_tvshows_url": None},
                  "Star Plus":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_plus.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/star-plus/",
                   "finished_tvshows_url": "/star-plus-past-shows/"},
                  "Zee TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/zz/zee_tv.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/zee-tv/",
                   "finished_tvshows_url": "/zee-tv-past-shows/"},
                  "Sony TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/set_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/sony-tv/",
                   "finished_tvshows_url": "/sony-tv-past-shows/"},
                  "Star One":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_one.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/star-one/",
                   "finished_tvshows_url": "/star-one-past-shows/"},
                  "Life OK":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ll/life_ok_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/life-ok/",
                   "finished_tvshows_url": None},
                  "Star Jalsha":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_jalsha.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/star-jalsha/",
                   "finished_tvshows_url": "/star-jalsha-past-shows/"},
                  "Sahara One":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/sahara_one.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/sahara-one/",
                   "finished_tvshows_url": "/sahara-one-past-shows/"},
                  "Colors":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/cc/colors_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/colors-channel/",
                   "finished_tvshows_url": "/colors-past-shows/"},
                  "NDTV Imagine":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ii/imagine_tv_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/ndtv-imagine/",
                   "finished_tvshows_url": "/ndtv-past-shows/"},
                  "Sab TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/sony_sab_tv.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/sab-tv/",
                   "finished_tvshows_url": "/sab-tv-past-shows/"},
                  "MTV (India/Pakistan)":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/mm/mtv_india.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/mtv-india-pakistan/",
                   "finished_tvshows_url": "/mtv-india-pakistan-past-shows/"},
                  "Bindass TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/uu/utv_bindass.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/bindass-tv/",
                   "finished_tvshows_url": "/bindass-tv-past-shows/"},
                  "Channel [V]":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/cc/channel_v_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/channel-v/",
                   "finished_tvshows_url": "/channel-v-past-shows/"},
                  "DD National":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/dd/dd_national.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/dd-national/",
                   "finished_tvshows_url": "/dd-national-others-past-shows/"},
                  "Ary Digital":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/aa/atn_ary_digital.jpg",
                   "channelType": "PAK",
                   "running_tvshows_url": "/ary-digital/",
                   "finished_tvshows_url": "/ary-past-shows/"},
                  "GEO TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/gg/geo_tv.jpg",
                   "channelType": "PAK",
                   "running_tvshows_url": "/geo-tv/",
                   "finished_tvshows_url": "/geo-tv-past-shows/"},
                  "HUM TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/hh/hum_tv.jpg",
                   "channelType": "PAK",
                   "running_tvshows_url": "/hum-tv/",
                   "finished_tvshows_url": "/hum-tv-past-shows/"},
                  "A PLUS":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/aa/a_plus.jpg",
                   "channelType": "PAK",
                   "running_tvshows_url": "/plus/",
                   "finished_tvshows_url": "/plus-past-shows/"},
                  "POGO":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/pp/pogo.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/pogo/",
                   "finished_tvshows_url": None},
                  "Nickelodeon":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/nn/nickelodeon_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/nick/",
                   "finished_tvshows_url": None},
                  "Disney Channel":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/dd/disney_channel_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/disney-channel/",
                   "finished_tvshows_url": None},
                  "Hungama TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/hh/hungama.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/hungama-tv/",
                   "finished_tvshows_url": None},
                  "Cartoon Network":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/cc/cartoon_network_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/cartoon-network/",
                   "finished_tvshows_url": None},
                  "Star Pravah":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_pravah.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/star-pravah/",
                   "finished_tvshows_url": None},
                  "Zee Marathi":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/zz/zee_marathi.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/zee-marathi/",
                   "finished_tvshows_url": None},
                  "Star Utsav":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_utsav.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/star-utsav/",
                   "finished_tvshows_url": None},
                  "9X":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/num/9x_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/9x/",
                   "finished_tvshows_url": "/9x-past-shows/"},
                  "ZEE Bangla":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/zz/zee_bangla.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/zee-bangla/",
                   "finished_tvshows_url": "/zee-bangla-past-shows/"},
                  "Mahuaa TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/mm/mahuaa_bangla.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/mahuaa-tv/",
                   "finished_tvshows_url": "/mahuaa-tv-past-shows/"}
                }
    
    XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__retrieveChannelTVShows__'), tvChannels.values(), 'Retrieving channel TV Shows', 'Failed to retrieve video information, please try again later', line1='Takes about 5 minutes first time', line3='Refreshes data every month or on force refresh or on new add-on version')
    #save tvChannels in moving data
    request_obj.get_data()['tvChannels'] = tvChannels
    status = AddonUtils.saveObjToJsonFile(filepath, tvChannels)
    if status is not None:
        print 'Saved status = ' + str(status)
    AddonContext().addon.setSetting('drForceRefresh', 'false')
Exemplo n.º 11
0
def retrieveTVShowsAndSave(request_obj, response_obj):
    oldfilepath = AddonUtils.getCompleteFilePath(baseDirPath=Container().getAddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=OLD_CHANNELS_JSON_FILE, makeDirs=True)
    AddonUtils.deleteFile(oldfilepath)
    
    filepath = AddonUtils.getCompleteFilePath(baseDirPath=Container().getAddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=True)
    refresh = Container().getAddonContext().addon.getSetting('drForceRefresh')
    if refresh == None or refresh != 'true':
        lastModifiedTime = AddonUtils.getFileLastModifiedTime(filepath)
        if lastModifiedTime is not None:
            diff = long((time.time() - lastModifiedTime) / 3600)
            if diff < 720:
                return
            else:
                Logger.logNotice(CHANNELS_JSON_FILE + ' was last created 30 days ago, refreshing data.')
    else:
        Logger.logNotice(CHANNELS_JSON_FILE + ' request to force refresh data. ')
    tvChannels = {"UTV Stars":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/uu/utv_stars.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=1274",
                   "finished_tvshows_url": "/forumdisplay.php?f=1435"},
                  "Star Plus":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_plus.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=42",
                   "finished_tvshows_url": "/forumdisplay.php?f=209"},
                  "Zee TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/zz/zee_tv.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=73",
                   "finished_tvshows_url": "/forumdisplay.php?f=211"},
                  "Sony TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/set_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=63",
                   "finished_tvshows_url": "/forumdisplay.php?f=210"},
                  "Life OK":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ll/life_ok_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=1375",
                   "finished_tvshows_url": "/forumdisplay.php?f=1581"},
                  "Star Jalsha":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_jalsha.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=667",
                   "finished_tvshows_url": "/forumdisplay.php?f=1057"},
                  "Sahara One":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/sahara_one.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=134",
                   "finished_tvshows_url": "/forumdisplay.php?f=213"},
                  "Colors":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/cc/colors_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=176",
                   "finished_tvshows_url": "/forumdisplay.php?f=374"},
                  "Sab TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/sony_sab_tv.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=254",
                   "finished_tvshows_url": "/forumdisplay.php?f=454"},
                  "MTV (India/Pakistan)":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/mm/mtv_india.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=339",
                   "finished_tvshows_url": "/forumdisplay.php?f=532"},
                  "Bindass TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/uu/utv_bindass.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=504",
                   "finished_tvshows_url": "/forumdisplay.php?f=960"},
                  "Channel [V]":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/cc/channel_v_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=633",
                   "finished_tvshows_url": "/forumdisplay.php?f=961"},
                  "DD National":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/dd/dd_national.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=535",
                   "finished_tvshows_url": "/forumdisplay.php?f=801"},
                  "Ary Digital":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/aa/atn_ary_digital.jpg",
                   "channelType": "PAK",
                   "running_tvshows_url": "/forumdisplay.php?f=384",
                   "finished_tvshows_url": "/forumdisplay.php?f=950"},
                  "GEO TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/gg/geo_tv.jpg",
                   "channelType": "PAK",
                   "running_tvshows_url": "/forumdisplay.php?f=413",
                   "finished_tvshows_url": "/forumdisplay.php?f=894"},
                  "HUM TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/hh/hum_tv.jpg",
                   "channelType": "PAK",
                   "running_tvshows_url": "/forumdisplay.php?f=448",
                   "finished_tvshows_url": "/forumdisplay.php?f=794"},
                  "A PLUS":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/aa/a_plus.jpg",
                   "channelType": "PAK",
                   "running_tvshows_url": "/forumdisplay.php?f=1327",
                   "finished_tvshows_url": "/forumdisplay.php?f=1334"},
                  "POGO":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/pp/pogo.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=500",
                   "finished_tvshows_url": None},
                  "Disney Channel":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/dd/disney_channel_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=479",
                   "finished_tvshows_url": None},
                  "Hungama TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/hh/hungama.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=472",
                   "finished_tvshows_url": "/forumdisplay.php?f=2102"},
                  "Cartoon Network":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/cc/cartoon_network_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=509",
                   "finished_tvshows_url": None},
                  "Star Pravah":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_pravah.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=1138",
                   "finished_tvshows_url": "/forumdisplay.php?f=1466"},
                  "Zee Marathi":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/zz/zee_marathi.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=1299",
                   "finished_tvshows_url": "/forumdisplay.php?f=1467"},
                  "Star Vijay":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_vijay_in.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=1609",
                   "finished_tvshows_url": "/forumdisplay.php?f=1747"},
                  "ZEE Bangla":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/zz/zee_bangla.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=676",
                   "finished_tvshows_url": "/forumdisplay.php?f=802"},
                  "Mahuaa TV":
                  {"iconimage":"http://www.lyngsat-logo.com/logo/tv/mm/mahuaa_bangla.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=772",
                   "finished_tvshows_url": "/forumdisplay.php?f=803"},
                  "Movies":
                  {"iconimage":"http://2.bp.blogspot.com/-8IURT2pXsb4/T5BqxR2OhfI/AAAAAAAACd0/cc5fwuEQIx8/s1600/the_movies.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=260",
                   "finished_tvshows_url": None},
                  "Latest & HQ Movies":
                  {"iconimage":"http://2.bp.blogspot.com/-8IURT2pXsb4/T5BqxR2OhfI/AAAAAAAACd0/cc5fwuEQIx8/s1600/the_movies.jpg",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=20",
                   "finished_tvshows_url": None},
                  "Awards & Concerts":
                  {"iconimage":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQGOu4sxdHNUQC8BUic5rcuMB3VbHf864dKIF7g65aNc2ozDxQQ",
                   "channelType": "IND",
                   "running_tvshows_url": "/forumdisplay.php?f=36",
                   "finished_tvshows_url": None},
                }
    
    XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__retrieveChannelTVShows__'), tvChannels.values(), 'Retrieving channel TV Shows', 'Failed to retrieve video information, please try again later', line1='Takes about 5 minutes first time', line3='Refreshes data every month or on force refresh or on new add-on version')
    # save tvChannels in moving data
    request_obj.get_data()['tvChannels'] = tvChannels
    status = AddonUtils.saveObjToJsonFile(filepath, tvChannels)
    if status is not None:
        Logger.logNotice('Saved status = ' + str(status))
    Container().getAddonContext().addon.setSetting('drForceRefresh', 'false')