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')