Skip to content

Commit

Permalink
Update to version 13 API
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister committed Jan 3, 2023
1 parent 30c2ed3 commit cfbebc5
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ msgid "Browse through the movie-catalogue"
msgstr ""

msgctxt "#30005"
msgid "Series"
msgid "Shorties"
msgstr ""

msgctxt "#30006"
msgid "Browse through the series-catalogue"
msgid "Browse through the shorties-catalogue"
msgstr ""

msgctxt "#30007"
Expand Down
8 changes: 4 additions & 4 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ msgid "Browse through the movie-catalogue"
msgstr "Doorblader de filmcatalogus"

msgctxt "#30005"
msgid "Series"
msgstr "Programma's"
msgid "Shorties"
msgstr "Shorties"

msgctxt "#30006"
msgid "Browse through the series-catalogue"
msgstr "Doorblader de programmacatalogus"
msgid "Browse through the shorties-catalogue"
msgstr "Doorblader de shortiescatalogus"

msgctxt "#30007"
msgid "Channels"
Expand Down
8 changes: 4 additions & 4 deletions resources/lib/modules/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from resources.lib import kodiutils
from resources.lib.modules import CHANNELS
from resources.lib.modules.menu import Menu
from resources.lib.vtmgo import STOREFRONT_MAIN, STOREFRONT_MOVIES, STOREFRONT_SERIES, Category
from resources.lib.vtmgo import STOREFRONT_MAIN, STOREFRONT_MOVIES, STOREFRONT_SHORTIES, Category
from resources.lib.vtmgo.exceptions import UnavailableException
from resources.lib.vtmgo.vtmgo import CACHE_PREVENT, ApiUpdateRequired, VtmGo
from resources.lib.vtmgo.vtmgoauth import VtmGoAuth
Expand Down Expand Up @@ -144,8 +144,8 @@ def show_recommendations(self, storefront):
else:
listing.append(Menu.generate_titleitem(item))

if storefront == STOREFRONT_SERIES:
label = 30005 # Series
if storefront == STOREFRONT_SHORTIES:
label = 30005 # Shorties
elif storefront == STOREFRONT_MOVIES:
label = 30003 # Movies
else:
Expand Down Expand Up @@ -174,7 +174,7 @@ def show_recommendations_category(self, storefront, category):
for item in result.content:
listing.append(Menu.generate_titleitem(item))

if storefront == STOREFRONT_SERIES:
if storefront == STOREFRONT_SHORTIES:
content = 'tvshows'
elif storefront == STOREFRONT_MOVIES:
content = 'movies'
Expand Down
6 changes: 3 additions & 3 deletions resources/lib/modules/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from resources.lib import kodiutils
from resources.lib.modules import CHANNELS
from resources.lib.vtmgo import STOREFRONT_KIDS, STOREFRONT_MAIN, STOREFRONT_MOVIES, STOREFRONT_SERIES, Episode, Movie, Program
from resources.lib.vtmgo import STOREFRONT_KIDS, STOREFRONT_MAIN, STOREFRONT_MOVIES, STOREFRONT_SHORTIES, Episode, Movie, Program
from resources.lib.vtmgo.vtmgo import CONTENT_TYPE_MOVIE, CONTENT_TYPE_PROGRAM

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -61,8 +61,8 @@ def show_mainmenu():
))

listing.append(kodiutils.TitleItem(
title=kodiutils.localize(30005), # Series
path=kodiutils.url_for('show_recommendations', storefront=STOREFRONT_SERIES),
title=kodiutils.localize(30005), # Shorties
path=kodiutils.url_for('show_recommendations', storefront=STOREFRONT_SHORTIES),
art_dict=dict(
icon='DefaultTVShows.png',
fanart=kodiutils.get_addon_info('fanart'),
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/vtmgo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# These seem to be hardcoded
STOREFRONT_MAIN = 'main'
STOREFRONT_MOVIES = 'movies'
STOREFRONT_SERIES = 'series'
STOREFRONT_SHORTIES = 'shorties'
STOREFRONT_KIDS = 'kids'


Expand Down
6 changes: 3 additions & 3 deletions resources/lib/vtmgo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
# Setup a static session that can be reused for all calls
SESSION = requests.Session()
SESSION.headers = {
'User-Agent': 'VTMGO/12.12 (be.vmma.vtm.zenderapp; build:16424; Android 24) okhttp/4.9.3',
'x-app-version': '12',
'User-Agent': 'VTM_GO/13.8 (be.vmma.vtm.zenderapp; build:17133; Android TV 28) okhttp/4.10.0',
'x-app-version': '13',
'x-persgroep-mobile-app': 'true',
'x-persgroep-os': 'android',
'x-persgroep-os-version': '24',
'x-persgroep-os-version': '28',
}

PROXIES = kodiutils.get_proxies()
Expand Down
12 changes: 6 additions & 6 deletions resources/lib/vtmgo/vtmgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, tokens):

def _mode(self):
""" Return the mode that should be used for API calls """
return 'vtmgo-kids' if self.get_product() == 'VTM_GO_KIDS' else 'vtmgo'
return 'vtmgo-kids' if self.get_product() == 'VTM_GO_KIDS' else 'VTM_GO'

@staticmethod
def get_config():
Expand Down Expand Up @@ -246,7 +246,7 @@ def get_program(self, program_id, cache=CACHE_AUTO):

if not program:
# Fetch from API
response = util.http_get(API_ENDPOINT + '/%s/programs/%s' % (self._mode(), program_id),
response = util.http_get(API_ENDPOINT + '/%s/detail/%s' % (self._mode(), program_id),
token=self._tokens.access_token if self._tokens else None,
profile=self._tokens.profile if self._tokens else None)
program = json.loads(response.text)
Expand All @@ -259,10 +259,10 @@ def get_program(self, program_id, cache=CACHE_AUTO):
episodes = {}

# Fetch season
season_response = util.http_get(API_ENDPOINT + '/%s/programs/%s/seasons/%s' % (self._mode(), program_id, item_season),
season_response = util.http_get(API_ENDPOINT + '/%s/detail/%s?selectedSeasonIndex=%s' % (self._mode(), program_id, item_season),
token=self._tokens.access_token if self._tokens else None,
profile=self._tokens.profile if self._tokens else None)
season = json.loads(season_response.text)
season = json.loads(season_response.text).get('selectedSeason')

for item_episode in season.get('episodes', []):
episodes[item_episode.get('index')] = Episode(
Expand All @@ -274,8 +274,8 @@ def get_program(self, program_id, cache=CACHE_AUTO):
name=item_episode.get('name'),
description=item_episode.get('description'),
duration=item_episode.get('durationSeconds'),
thumb=item_episode.get('bigPhotoUrl'),
fanart=item_episode.get('bigPhotoUrl'),
thumb=item_episode.get('imageUrl'),
fanart=item_episode.get('imageUrl'),
geoblocked=program.get('blockedFor') == 'GEO',
remaining=item_episode.get('remainingDaysAvailable'),
channel=channel,
Expand Down
10 changes: 5 additions & 5 deletions resources/lib/vtmgo/vtmgoauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def authorize_check(self):
self._account.refresh_token = auth_info.get('refresh_token')

# Fetch an actual token we can use
response = util.http_post('https://lfvp-api.dpgmedia.net/vtmgo/tokens', data={
response = util.http_post('https://lfvp-api.dpgmedia.net/VTM_GO/tokens', data={
'device': {
'id': str(uuid.uuid4()),
'name': 'VTM Go Addon on Kodi',
Expand All @@ -142,7 +142,7 @@ def get_tokens(self):
return self._account

# We can refresh our old token so it's valid again
response = util.http_post('https://lfvp-api.dpgmedia.net/vtmgo/tokens/refresh', data={
response = util.http_post('https://lfvp-api.dpgmedia.net/VTM_GO/tokens/refresh', data={
'lfvpToken': self._account.access_token,
})

Expand All @@ -158,9 +158,9 @@ def get_tokens(self):

return self._account

def get_profiles(self, products='VTM_GO,VTM_GO_KIDS'):
def get_profiles(self):
""" Returns the available profiles """
response = util.http_get(API_ENDPOINT + '/profiles', {'products': products}, token=self._account.access_token)
response = util.http_get(API_ENDPOINT + '/VTM_GO/profiles', token=self._account.access_token)
result = json.loads(response.text)

profiles = [
Expand All @@ -173,7 +173,7 @@ def get_profiles(self, products='VTM_GO,VTM_GO_KIDS'):
color=profile.get('color', {}).get('start'),
color2=profile.get('color', {}).get('end'),
)
for profile in result
for profile in result.get('profiles')
]

return profiles
Expand Down
4 changes: 2 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from resources.lib import kodiutils
from resources.lib.modules.player import Player
from resources.lib.vtmgo import STOREFRONT_MAIN, STOREFRONT_MOVIES, STOREFRONT_SERIES, Category
from resources.lib.vtmgo import STOREFRONT_MAIN, STOREFRONT_MOVIES, STOREFRONT_SHORTIES, Category
from resources.lib.vtmgo.vtmgo import VtmGo
from resources.lib.vtmgo.vtmgoauth import VtmGoAuth

Expand Down Expand Up @@ -43,7 +43,7 @@ def test_recommendations(self):
results = self.api.get_storefront(STOREFRONT_MOVIES)
self.assertIsInstance(results, list)

results = self.api.get_storefront(STOREFRONT_SERIES)
results = self.api.get_storefront(STOREFRONT_SHORTIES)
self.assertIsInstance(results, list)

def test_mylist(self):
Expand Down

0 comments on commit cfbebc5

Please sign in to comment.