Skip to content

Commit

Permalink
remove unnecessary "encode('utf-8')"
Browse files Browse the repository at this point in the history
switch to unicode strings for all strings
fix some issues with python 3
  • Loading branch information
fayer3 committed Aug 8, 2019
1 parent 8e23156 commit 378b397
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 147 deletions.
8 changes: 4 additions & 4 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<email>fb4472 (at) aon.at</email>
<source>https://github.com/fayer3/plugin.video.zappntv</source>
<news>- EPG hinzugefügt
- JOYN Favoriten hinzugefügt
- Suche hinzugefügt
- Name von TV shows korregiert
- VOD auf lebreelec korregiert
- JOYN Favoriten hinzugefügt
- Suche hinzugefügt
- Name von TV shows korregiert
- VOD auf lebreelec korregiert
</news>
<assets>
<icon>resources/icon.png</icon>
Expand Down
23 changes: 20 additions & 3 deletions favorite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
import json
import sys

import xbmcaddon
import xbmcvfs
Expand All @@ -17,7 +18,7 @@

def log(info):
if kodiutils.get_setting_as_bool("debug"):
logger.warning(info.decode('ascii', 'ignore').encode('ascii','ignore'))
logger.warning(info)

logger = logging.getLogger(xbmcaddon.Addon().getAddonInfo('id'))
kodilogging.config()
Expand All @@ -29,7 +30,7 @@ def log(info):

favorites_file_path = __profile__+"favorites.json"

log('launched: favorit.py with {0} arguments'.format(len(sys.argv)))
log(u'launched: favorit.py with {0} arguments'.format(len(sys.argv)))

log(str(sys.argv))

Expand All @@ -38,13 +39,24 @@ def log(info):
# get parameters
path = unquote(sys.argv[2])
name = unquote(sys.argv[3])
log('add favorite: {0}, {1}'.format(path, name))
desc = unquote_plus(sys.argv[4])
icon = unquote(sys.argv[5])
poster = unquote(sys.argv[6])
thumbnail = unquote(sys.argv[7])
fanart = unquote(sys.argv[8])

if sys.version_info[0] < 3:
# decode utf-8
path = path.decode('utf-8')
name = name.decode('utf-8')
desc = desc.decode('utf-8')
icon = icon.decode('utf-8')
poster = poster.decode('utf-8')
thumbnail = thumbnail.decode('utf-8')
fanart = fanart.decode('utf-8')

log(u'add favorite: {0}, {1}'.format(path, name))

# load favorites
favorites = {}
if not favorites and xbmcvfs.exists(favorites_file_path):
Expand All @@ -62,6 +74,11 @@ def log(info):
xbmc.executebuiltin('Container.Refresh')
elif sys.argv[1] == 'remove' and len(sys.argv) == 3:
data = unquote(sys.argv[2])

if sys.version_info[0] < 3:
# decode utf-8
data = data.decode('utf-8')

# load favorites
favorites = {}
if not favorites and xbmcvfs.exists(favorites_file_path):
Expand Down
64 changes: 32 additions & 32 deletions resources/lib/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,72 @@
if not xbmcvfs.exists(__profile__):
xbmcvfs.mkdirs(__profile__)

cache_file_path = __profile__ + "config_cache.json"
tag_file_path = __profile__ + "tag_cache.json"
cache_file_path = __profile__ + u'config_cache.json'
tag_file_path = __profile__ + u'tag_cache.json'

# data for requests

user_agent = 'Joyn Android App build/301003149 release/3.1.0'
user_agent = u'Joyn Android App build/301003149 release/3.1.0'

# from app
middleware_token = '1ec991118fe49ca44c185ee6a86354ef'
middleware_token = u'1ec991118fe49ca44c185ee6a86354ef'

# from https://psf.player.v0.maxdome.cloud/dist/playback-source-fetcher.min.js
xxtea_key = '5C7838365C7864665C786638265C783064595C783935245C7865395C7838323F5C7866333D3B5C78386635'
xxtea_key = u'5C7838365C7864665C786638265C783064595C783935245C7865395C7838323F5C7866333D3B5C78386635'

config_url = 'https://playerconfig.prd.platform.s.joyn.de/df0aba535c694114d8e2b193b9affd97.json'
config_url = u'https://playerconfig.prd.platform.s.joyn.de/df0aba535c694114d8e2b193b9affd97.json'

base_url = 'https://middleware.p7s1.io/joyn/v1/'
base_url = u'https://middleware.p7s1.io/joyn/v1/'

overview_url = base_url + 'ui?path=/'
overview_url = base_url + u'ui?path=/'
#livestream_url = 'https://middleware.p7s1.io/joyn/v1/brands?selection={data{id, channelId ,agofCodes,metadata}}&streamIds=true&mock=false'
livestream_url = base_url + 'brands?selection=%7Bdata%7Bid%2C%20channelId%20%2CagofCodes%2Cmetadata%7D%7D&streamIds=true&mock=false'
livestream_url = base_url + u'brands?selection=%7Bdata%7Bid%2C%20channelId%20%2CagofCodes%2Cmetadata%7D%7D&streamIds=true&mock=false'

#https://middleware.p7s1.io/joyn/v1/epg?selection={totalCount,data{id,title,description,tvShow,type,productionYear,tvChannelName,channelId,startTime,endTime,repeatTime,video,genres{type,title},images(subType:"cover,logo,art_direction"){url,subType}}}&skip=0&limit=1000&from={0}&to={1}&sortBy=startTime&sortAscending=true'
epg_url = base_url + 'epg?selection=%7BtotalCount%2Cdata%7Bid%2Ctitle%2Cdescription%2CtvShow%2Ctype%2CproductionYear%2CtvChannelName%2CchannelId%2CstartTime%2CendTime%2CrepeatTime%2Cvideo%2Cgenres%7Btype%2Ctitle%7D%2Cimages%28subType%3A%22cover%2Clogo%2Cart_direction%22%29%7Burl%2CsubType%7D%7D%7D&skip=0&limit=1000&from={0}&to={1}&sortBy=startTime&sortAscending=true'
epg_url = base_url + u'epg?selection=%7BtotalCount%2Cdata%7Bid%2Ctitle%2Cdescription%2CtvShow%2Ctype%2CproductionYear%2CtvChannelName%2CchannelId%2CstartTime%2CendTime%2CrepeatTime%2Cvideo%2Cgenres%7Btype%2Ctitle%7D%2Cimages%28subType%3A%22cover%2Clogo%2Cart_direction%22%29%7Burl%2CsubType%7D%7D%7D&skip=0&limit=1000&from={0}&to={1}&sortBy=startTime&sortAscending=true'

epg_now_url = base_url + 'epg/now?selection=%7BtotalCount%2Cdata%7Bid%2Ctitle%2Cdescription%2CtvShow%2Ctype%2CproductionYear%2CtvChannelName%2CchannelId%2CstartTime%2CendTime%2CrepeatTime%2Cvideo%2Cgenres%7Btype%2Ctitle%7D%2Cimages%28subType%3A%22cover%2Clogo%2Cart_direction%22%29%7Burl%2CsubType%7D%7D%7D&skip=0&limit=5000&sortAscending=true'
epg_now_url = base_url + u'epg/now?selection=%7BtotalCount%2Cdata%7Bid%2Ctitle%2Cdescription%2CtvShow%2Ctype%2CproductionYear%2CtvChannelName%2CchannelId%2CstartTime%2CendTime%2CrepeatTime%2Cvideo%2Cgenres%7Btype%2Ctitle%7D%2Cimages%28subType%3A%22cover%2Clogo%2Cart_direction%22%29%7Burl%2CsubType%7D%7D%7D&skip=0&limit=5000&sortAscending=true'

epg_channel_url = base_url + 'epg?selection=%7BtotalCount%2Cdata%7Bid%2Ctitle%2Cdescription%2CtvShow%2Ctype%2CproductionYear%2CtvChannelName%2CchannelId%2CstartTime%2CendTime%2CrepeatTime%2Cvideo%2Cgenres%7Btype%2Ctitle%7D%2Cimages%28subType%3A%22cover%2Clogo%2Cart_direction%22%29%7Burl%2CsubType%7D%7D%7D&skip=0&limit=1000&sortBy=startTime&sortAscending=true&channelId={channel}'
epg_channel_url = base_url + u'epg?selection=%7BtotalCount%2Cdata%7Bid%2Ctitle%2Cdescription%2CtvShow%2Ctype%2CproductionYear%2CtvChannelName%2CchannelId%2CstartTime%2CendTime%2CrepeatTime%2Cvideo%2Cgenres%7Btype%2Ctitle%7D%2Cimages%28subType%3A%22cover%2Clogo%2Cart_direction%22%29%7Burl%2CsubType%7D%7D%7D&skip=0&limit=1000&sortBy=startTime&sortAscending=true&channelId={channel}'

fetch_url = base_url + 'fetch/{0}'
fetch_url = base_url + u'fetch/{0}'
#fetch_selection = 'selection={data{id,visibilities, channelId ,agofCodes,duration,metadata{de}}}'
fetch_selection = 'selection=%7Bdata%7Bid%2Cvisibilities%2C%20channelId%20%2CagofCodes%2Cduration%2Cmetadata%7Bde%7D%7D%7D'
fetch_selection = u'selection=%7Bdata%7Bid%2Cvisibilities%2C%20channelId%20%2CagofCodes%2Cduration%2Cmetadata%7Bde%7D%7D%7D'

seasons_url = base_url + 'seasons?tvShowId={0}&subType=Hauptfilm&sortBy=seasonsOrder&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&sortAscending=true'
seasons_url = base_url + u'seasons?tvShowId={0}&subType=Hauptfilm&sortBy=seasonsOrder&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&sortAscending=true'
#seasons_selection = '&subType=Hauptfilm&sortBy=seasonsOrder&selection={data{id,channelId,visibilities,duration,metadata{de}}}&sortAscending=true'

season_url = base_url + 'videos?seasonId={0}&sortBy=seasonsOrder&sortAscending=true&skip=0&subType=Hauptfilm&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2CtvShow%2Cmetadata%7Bde%7D%7D%7D'
season_url = base_url + u'videos?seasonId={0}&sortBy=seasonsOrder&sortAscending=true&skip=0&subType=Hauptfilm&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2CtvShow%2Cmetadata%7Bde%7D%7D%7D'
#season_selection = '&sortBy=seasonsOrder&sortAscending=true&skip=0&subType=Hauptfilm&selection={data{id,channelId,visibilities,duration,metadata{de}}}'

tvshow_url = base_url + 'tvshows?ids={0}&limit=1&subType=Hauptfilm&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&filter=visible&type=tvShow'
tvshow_url = base_url + u'tvshows?ids={0}&limit=1&subType=Hauptfilm&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&filter=visible&type=tvShow'
#tvshow_selection = '&limit=1&subType=Hauptfilm&selection={data{id,channelId,visibilities,duration,metadata{de}}}&filter=visible&type=tvShow'

channel_url = base_url + 'tvshows?skip={0}&limit=5000&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&filter=visible&type=tvShow%2Cmovie&channelId={1}'
channel_url = base_url + u'tvshows?skip={0}&limit=5000&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&filter=visible&type=tvShow%2Cmovie&channelId={1}'
channel_limit = 5000

search_tvshow_url = base_url + 'tvshows?search={0}&limit=5000&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&filter=visible&type=tvShow'
search_movie_url = base_url + 'tvshows?search={0}&limit=5000&subType=Hauptfilm&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&filter=visible&type=movie'
search_tvshow_url = base_url + u'tvshows?search={0}&limit=5000&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&filter=visible&type=tvShow'
search_movie_url = base_url + u'tvshows?search={0}&limit=5000&subType=Hauptfilm&selection=%7Bdata%7Bid%2CchannelId%2Cvisibilities%2Cduration%2Cmetadata%7Bde%7D%7D%7D&filter=visible&type=movie'
search_limit = 5000

video_info_url = base_url + 'metadata/video/{0}?country=de&devicetype=phone&recommendations=2'
video_info_url = base_url + u'metadata/video/{0}?country=de&devicetype=phone&recommendations=2'

image_url = '{0}/profile:original'
image_url = u'{0}/profile:original'

player_config_url = 'https://playerconfig.prd.platform.s.joyn.de/df0aba535c694114d8e2b193b9affd97.json'
player_config_url = u'https://playerconfig.prd.platform.s.joyn.de/df0aba535c694114d8e2b193b9affd97.json'

psf_config_url = 'https://psf.player.v0.maxdome.cloud/config/psf.json'
psf_config_url = u'https://psf.player.v0.maxdome.cloud/config/psf.json'

entitlement_token_url = 'entitlement-token/anonymous'
entitlement_token_url = u'entitlement-token/anonymous'

nuggvars_url = 'https://71iapp-cp.nuggad.net/rc?nuggn=2011964291&nuggsid=1282618500&nuggtg=TV_DRAMA,EDITORIAL_CONT_VIDEO&tok='
nuggvars_url = u'https://71iapp-cp.nuggad.net/rc?nuggn=2011964291&nuggsid=1282618500&nuggtg=TV_DRAMA,EDITORIAL_CONT_VIDEO&tok='

video_playback_url = 'playout/video/{episode_id}?entitlement_token={entitlement_token}&clientData={clientData}&sig={sig}'
live_playback_url = 'playout/channel/{stream_id}?entitlement_token={entitlement_token}&clientData={clientData}&sig={sig}'
video_playback_url = u'playout/video/{episode_id}?entitlement_token={entitlement_token}&clientData={clientData}&sig={sig}'
live_playback_url = u'playout/channel/{stream_id}?entitlement_token={entitlement_token}&clientData={clientData}&sig={sig}'

clientdata = '{{"adconfigurl":null,"idfa":"","noAdCooldown":true,"npa":false,"nuggvars":"{nuggvars}","ppid":"","startTime":0,"videoId":"{episode_id}","duration":{duration},"brand":"{brand}","genre":{genres},"tvshowid":"{tvshow_id}"}}'
clientdata = u'{{"adconfigurl":null,"idfa":"","noAdCooldown":true,"npa":false,"nuggvars":"{nuggvars}","ppid":"","startTime":0,"videoId":"{episode_id}","duration":{duration},"brand":"{brand}","genre":{genres},"tvshowid":"{tvshow_id}"}}'

clientdata_live = '{{"adconfigurl":null,"idfa":"","noAdCooldown":true,"npa":false,"nuggvars":"0","ppid":"","startTime":0,"videoId":"{stream_id}","brand":"{brand}","genre":[]}}'
clientdata_live = u'{{"adconfigurl":null,"idfa":"","noAdCooldown":true,"npa":false,"nuggvars":"0","ppid":"","startTime":0,"videoId":"{stream_id}","brand":"{brand}","genre":[]}}'

config_cache = {}
config_tag = {}
Expand All @@ -91,7 +91,7 @@ def get_config_cache(url):
cache_file.close()
if url in config_cache:
return config_cache[url]
return ""
return u''

def get_config_tag(url):
global config_tag
Expand All @@ -101,7 +101,7 @@ def get_config_tag(url):
tag_file.close()
if url in config_tag:
return config_tag[url]
return ""
return u''

def set_config_cache(url, data, tag):
global config_cache
Expand Down
Loading

0 comments on commit 378b397

Please sign in to comment.