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

Videostar: API URL and authorization fixes #938

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion plugin.video.mrknowtv/resources/lib/indexers/tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self):
self.datetime = (datetime.datetime.utcnow() - datetime.timedelta(hours = 5))
self.systime = (self.datetime).strftime('%Y%m%d%H%M%S%f')
self.telewizjadanet_link = 'http://www.telewizjada.net'
self.videostar_link = 'https://api.videostar.pl'
self.videostar_link = 'https://api-pilot.wp.pl'
self.yoy_link = 'http://yoy.tv'
self.weeb_link = 'http://weeb.tv'
self.wizja_link = 'http://wizja.tv'
Expand Down Expand Up @@ -395,6 +395,9 @@ def videostar_list(self, url):
result = videostar.get('/channels/list/ios-plus')
result = json.loads(result)
control.log('A tv.get %s' % result)
if result['status'] == 'error':
control.infoDialog(result['errors'][0]['msg'])
raise Exception(result['errors'][0]['msg'])
for i in result['channels']:
control.log('Result %s' % i)
if i['access_status']== 'subscribed' or i['access_status']== 'free':
Expand Down
30 changes: 16 additions & 14 deletions plugin.video.mrknowtv/resources/lib/sources/videostar.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@
headers = {'User-Agent': 'videostar/1.47 CFNetwork/808.1.4 Darwin/16.1.0'}


def get(url, proxy=''):
def get(url, proxy='', retry=True):
try:
pl_proxy = control.setting('pl_proxy')
pl_proxy_port = control.setting('pl_proxy_port')

if getVideostarCredentialsInfo() == False:
control.infoDialog('Enter credentials')
if control.yesnoDialog(control.lang(40001).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')):
control.openSettings('1.11')
raise Exception()
return None

url = urlparse.urljoin('https://api.videostar.pl', url)
full_url = urlparse.urljoin('https://api-pilot.wp.pl', url)
if proxy == '':
result = client.request(url, headers=headers, cookie=control.get_setting('videostar.sess'))
result = client.request(full_url, headers=headers, cookie=control.get_setting('videostar.sess'))
else:
myproxy = pl_proxy
if pl_proxy_port != '': myproxy = myproxy + ':' + pl_proxy_port
Expand All @@ -51,15 +52,13 @@ def get(url, proxy=''):
control.openSettings('0.11')
return None

result = client.request(url, headers=headers, cookie=control.get_setting('videostar.sess'), proxy=myproxy)
result = client.request(full_url, headers=headers, cookie=control.get_setting('videostar.sess'), proxy=myproxy)

r = json.loads(result)

if r['status'] =="error" or result==None:
if r['errors'][0]['code'] == 1:
login()
control.sleep(500)
mycookie = control.get_setting('videostar.sess')
result = client.source(url, headers=headers, cookie=control.get_setting('videostar.sess'))
if (r['status'] =="error" or result==None) and retry:
login()
result = get(url, proxy, False);

return result
except Exception as e:
Expand All @@ -75,13 +74,16 @@ def login():
params['login'] = control.get_setting('videostar.user')
params['password'] = control.get_setting('videostar.pass')
params['permanent']=1
url = 'https://api.videostar.pl/user/login'
url = 'https://api-pilot.wp.pl/user/login'
result = client.request(url, post=params, headers=headers, output='cookie')
control.log('ResultC videostar.get %s' % result)
if result == '':
control.infoDialog('Unauthorized')
return None

control.set_setting('videostar.sess', result)
control.sleep(500)
url='https://api.videostar.pl/invitations/limit'
url='https://api-pilot.wp.pl/invitations/limit'
headers['cookie']=result
result2 = client.request(url, headers=headers)
if 'error' in result2:
Expand Down Expand Up @@ -109,7 +111,7 @@ def getstream(id):
pl_proxy_port = control.setting('pl_proxy_port')


url = 'https://api.videostar.pl/channels/get/%s?format_id=2' % id
url = 'https://api-pilot.wp.pl/channels/get/%s?format_id=2' % id
result = get(url,pl_proxy)
control.log('Z %s' % result)
result = json.loads(result)
Expand Down