-
Notifications
You must be signed in to change notification settings - Fork 4
/
streamplayer.py
59 lines (49 loc) · 1.64 KB
/
streamplayer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import xbmc
from common import addon_log
from resources.digi.digi import Digi
import requests
class streamplayer(xbmc.Player):
deviceId = None
DOSESSV3PRI = None
fakeRequest = None
def __init__(self, *args, **kwargs):
# self.cookieFile = kwargs.get('cookieFile')
if(kwargs.get('deviceId')):
self.deviceId = kwargs.get('deviceId')
if(kwargs.get('DOSESSV3PRI')):
self.DOSESSV3PRI = kwargs.get('DOSESSV3PRI')
if(kwargs.get('fakeRequest')):
self.fakeRequest = kwargs.get('fakeRequest')
self.player_status = None
xbmc.Player.__init__(self)
def play(self, url, listitem):
self.player_status = 'play'
self.digiFakeRequest(url)
super(streamplayer, self).play(url, listitem)
self.keep_allive(url)
def onPlayBackEnded(self):
addon_log('----------------------->END PLAY')
self.player_status = 'end'
def onPlayBackStopped(self):
addon_log('----------------------->STOP PLAY')
self.player_status = 'stop'
def keep_allive(self, url):
#KEEP SCRIPT ALLIVE
time = 0
interval = 500
while (self.player_status=='play'):
addon_log('ALLIVE')
xbmc.sleep(500)
time += interval
if(time > 60 * 1000):
time = 0
self.digiFakeRequest(url)
def digiFakeRequest(self, url):
if(self.deviceId and self.DOSESSV3PRI):
digi = Digi(deviceId=self.deviceId, DOSESSV3PRI=self.DOSESSV3PRI)
m3u = digi.getPage(url) # needed for android devices to be accessed as browser before play otherwise we get 401 error
addon_log(m3u)
else:
if (self.fakeRequest):
response = requests.get(url)
addon_log(response.text)