Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw decent error on a geoblock exception #329

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion resources/lib/vtmgo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

from __future__ import absolute_import, division, unicode_literals

import json
import logging

import requests
from requests import HTTPError

from resources.lib import kodiutils
from resources.lib.vtmgo.exceptions import InvalidLoginException, InvalidTokenException, LimitReachedException, UnavailableException
from resources.lib.vtmgo.exceptions import InvalidLoginException, InvalidTokenException, LimitReachedException, UnavailableException, StreamGeoblockedException

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -44,6 +45,12 @@ def http_get(url, params=None, token=None, profile=None, headers=None):
if exc.response.status_code == 401:
raise InvalidTokenException(exc)
if exc.response.status_code == 403:
try:
body = json.loads(exc.response.content)
except Exception: # pylint: disable=broad-except
body = {}
if body.get('type') == 'videoPlaybackGeoblocked':
raise StreamGeoblockedException(exc)
raise InvalidLoginException(exc)
if exc.response.status_code == 404:
raise UnavailableException(exc)
Expand Down