diff --git a/addon.xml b/addon.xml index 04088e1..78a62f8 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ - + - + @@ -29,6 +29,7 @@ Setup: + v2.0.0 - Python 3 update v1.3.0 - fix server issues for lineups (2019-04-12) v1.2.0 - add option to refresh download cache days (2019-03-04) v1.1.0 - added ability to refresh TBA episodes (2018-11-20) diff --git a/changelog.txt b/changelog.txt index 76af2f5..8dab996 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,9 @@ +v2.0.0 (2020-10-27) + - Python3 update + v1.3.0 (2019-04-12) - fix server issues for lineups - + v1.2.0 (2019-03-04) - add option to refresh download cache days diff --git a/default.py b/default.py index c49e55e..51134fc 100644 --- a/default.py +++ b/default.py @@ -17,13 +17,13 @@ import subprocess from subprocess import Popen from xbmcswift2 import Plugin -import StringIO +import io import os import re import sys import logging import zap2epg -import urllib2 +import urllib.request, urllib.error, urllib.parse import json from collections import OrderedDict import time @@ -97,7 +97,7 @@ def create_cList(): channels = response.json() with open(tvhList,"w") as f: json.dump(channels,f) - except urllib2.HTTPError as e: + except urllib.error.HTTPError as e: logging.exception('Exception: tvhClist - %s', e.strerror) pass with open(tvhList) as tvhData: @@ -108,7 +108,7 @@ def create_cList(): tvhClist.append(ch['number']) lineupcode = xbmcaddon.Addon().getSetting('lineupcode') url = 'http://tvlistings.zap2it.com/api/grid?lineupId=×pan=3&headendId=' + lineupcode + '&country=' + country + '&device=' + device + '&postalCode=' + zipcode + '&time=' + str(gridtime) + '&pref=-&userId=-' - content = urllib2.urlopen(url).read() + content = urllib.request.urlopen(url).read() contentDict = json.loads(content) stationDict = {} if 'channels' in contentDict: @@ -121,7 +121,7 @@ def create_cList(): stationDict[skey]['include'] = 'True' else: stationDict[skey]['include'] = 'False' - stationDictSort = OrderedDict(sorted(stationDict.iteritems(), key=lambda i: (float(i[1]['num'])))) + stationDictSort = OrderedDict(sorted(iter(stationDict.items()), key=lambda i: (float(i[1]['num'])))) with open(Clist,"w") as f: json.dump(stationDictSort,f) @@ -139,7 +139,7 @@ def channels(): create_cList() with open(Clist) as data: stationDict = json.load(data) - stationDict = OrderedDict(sorted(stationDict.iteritems(), key=lambda i: (float(i[1]['num'])))) + stationDict = OrderedDict(sorted(iter(stationDict.items()), key=lambda i: (float(i[1]['num'])))) stationCode = [] stationListName = [] stationListNum = [] @@ -150,7 +150,7 @@ def channels(): stationListNum.append(stationDict[station]['num']) stationListInclude.append(stationDict[station]['include']) stationPre = [i for i, x in enumerate(stationListInclude) if x == 'True'] - stationListFull = zip(stationListNum, stationListName) + stationListFull = list(zip(stationListNum, stationListName)) stationList = ["%s %s" % x for x in stationListFull] selCh = dialog.multiselect('Click to Select Channels to Include', stationList, preselect=stationPre) for station in stationDict: @@ -191,7 +191,7 @@ def location(): lineupsN = ['AVAILABLE LINEUPS', 'TIMEZONE - Eastern', 'TIMEZONE - Central', 'TIMEZONE - Mountain', 'TIMEZONE - Pacific'] lineupsC = ['NONE', 'DFLTEC', 'DFLTCC', 'DFLTMC', 'DFLTPC'] deviceX = ['-', '-', '-', '-', '-'] - content = urllib2.urlopen(url).read() + content = urllib.request.urlopen(url).read() lineupDict = json.loads(content) if 'Providers' in lineupDict: for provider in lineupDict['Providers']: @@ -253,25 +253,25 @@ def index(): items.append( { 'label': 'Run zap2epg and Update Guide Data', - 'path': plugin.url_for(u'run'), + 'path': plugin.url_for('run'), 'thumbnail':get_icon_path('run'), }) items.append( { 'label': 'Change Current Location | Zipcode: ' + zipcode + ' & Lineup: ' + lineup, - 'path': plugin.url_for(u'location'), + 'path': plugin.url_for('location'), 'thumbnail':get_icon_path('antenna'), }) items.append( { 'label': 'Configure Channel List', - 'path': plugin.url_for(u'channels'), + 'path': plugin.url_for('channels'), 'thumbnail':get_icon_path('channel'), }) items.append( { 'label': 'Configure Settings and Options', - 'path': plugin.url_for(u'open_settings'), + 'path': plugin.url_for('open_settings'), 'thumbnail':get_icon_path('settings'), }) return items diff --git a/zap2epg.py b/zap2epg.py index 2f74896..c9540f5 100644 --- a/zap2epg.py +++ b/zap2epg.py @@ -14,7 +14,7 @@ # along with this program. If not, see . ################################################################################ -import urllib2 +import urllib.request, urllib.error, urllib.parse import base64 import codecs import time @@ -110,11 +110,11 @@ def tvhMatchGet(): channels_url = tvhUrlBase + '/api/channel/grid?all=1&limit=999999999&sort=name&filter=[{"type":"boolean","value":true,"field":"enabled"}]' if usern is not None and passw is not None: logging.info('Adding Tvheadend username and password to request url...') - request = urllib2.Request(channels_url) + request = urllib.request.Request(channels_url) request.add_header('Authorization', b'Basic ' + base64.b64encode(usern + b':' + passw)) - response = urllib2.urlopen(request) + response = urllib.request.urlopen(request) else: - response = urllib2.urlopen(channels_url) + response = urllib.request.urlopen(channels_url) try: logging.info('Accessing Tvheadend channel list from: %s', tvhUrlBase) channels = json.load(response) @@ -123,7 +123,7 @@ def tvhMatchGet(): channelNum = ch['number'] tvhMatchDict[channelNum] = channelName logging.info('%s Tvheadend channels found...', str(len(tvhMatchDict))) - except urllib2.HTTPError as e: + except urllib.error.HTTPError as e: logging.exception('Exception: tvhMatch - %s', e.strerror) pass @@ -140,7 +140,7 @@ def deleteOldCache(gridtimeStart): try: os.remove(fn) logging.info('Deleting old cache: %s', entry) - except OSError, e: + except OSError as e: logging.warn('Error Deleting: %s - %s.' % (e.filename, e.strerror)) except Exception as e: logging.exception('Exception: deleteOldCache - %s', e.strerror) @@ -158,7 +158,7 @@ def deleteOldShowCache(showList): try: os.remove(fn) logging.info('Deleting old show cache: %s', entry) - except OSError, e: + except OSError as e: logging.warn('Error Deleting: %s - %s.' % (e.filename, e.strerror)) except Exception as e: logging.exception('Exception: deleteOldshowCache - %s', e.strerror) @@ -267,9 +267,9 @@ def printStations(fh): try: logging.info('Writing Stations to xmltv.xml file...') try: - scheduleSort = OrderedDict(sorted(schedule.iteritems(), key=lambda x: int(x[1]['chnum']))) + scheduleSort = OrderedDict(sorted(iter(schedule.items()), key=lambda x: int(x[1]['chnum']))) except: - scheduleSort = OrderedDict(sorted(schedule.iteritems(), key=lambda x: x[1]['chfcc'])) + scheduleSort = OrderedDict(sorted(iter(schedule.items()), key=lambda x: x[1]['chfcc'])) for station in scheduleSort: fh.write('\t\n') if 'chtvh' in scheduleSort[station] and scheduleSort[station]['chtvh'] is not None: @@ -533,8 +533,8 @@ def parseXdetails(): url = 'https://tvlistings.zap2it.com/api/program/overviewDetails' data = 'programSeriesID=' + EPseries try: - URLcontent = urllib2.Request(url, data=data) - JSONcontent = urllib2.urlopen(URLcontent).read() + URLcontent = urllib.request.Request(url, data=data) + JSONcontent = urllib.request.urlopen(URLcontent).read() if JSONcontent: with open(fileDir,"wb+") as f: f.write(JSONcontent) @@ -544,7 +544,7 @@ def parseXdetails(): time.sleep(1) retry -= 1 logging.warn('Retry downloading missing details data for: %s', EPseries) - except urllib2.URLError, e: + except urllib.error.URLError as e: time.sleep(1) retry -= 1 logging.warn('Retry downloading details data for: %s - %s', EPseries, e) @@ -583,7 +583,7 @@ def parseXdetails(): os.remove(fileDir) logging.info('Deleting %s due to TBA listings', filename) showList.remove(edict['epseries']) - except OSError, e: + except OSError as e: logging.warn('Error Deleting: %s - %s.' % (e.filename, e.strerror)) except Exception as e: logging.exception('Could not parse TBAcheck for: %s - %s', episode, e) @@ -616,14 +616,14 @@ def addXDetails(edict): prog = "" plot= "" descsort = "" - bullet = u"\u2022 " - hyphen = u"\u2013 " + bullet = "\u2022 " + hyphen = "\u2013 " newLine = "\n" space = " " - colon = u"\u003A " - vbar = u"\u007C " - slash = u"\u2215 " - comma = u"\u002C " + colon = "\u003A " + vbar = "\u007C " + slash = "\u2215 " + comma = "\u002C " def getSortName(opt): return { @@ -759,7 +759,7 @@ def makeDescsortList(optList): try: logging.info('Downloading guide data for: %s', str(gridtime)) url = 'http://tvlistings.zap2it.com/api/grid?lineupId=×pan=3&headendId=' + lineupcode + '&country=' + country + '&device=' + device + '&postalCode=' + zipcode + '&time=' + str(gridtime) + '&pref=-&userId=-' - saveContent = urllib2.urlopen(url).read() + saveContent = urllib.request.urlopen(url).read() savepage(fileDir, saveContent) except: logging.warn('Could not download guide data for: %s', str(gridtime)) @@ -777,7 +777,7 @@ def makeDescsortList(optList): try: os.remove(fileDir) logging.info('Deleting %s due to TBA listings', filename) - except OSError, e: + except OSError as e: logging.warn('Error Deleting: %s - %s.' % (e.filename, e.strerror)) except: logging.warn('JSON file error for: %s - deleting file', filename)