mbebe / blomqvist

blomqvist
GNU General Public License v3.0
156 stars 56 forks source link

PolsatGo #597

Open mbebe opened 3 years ago

mbebe commented 3 years ago

J.w. dodany do repo. bezp. link : plugin.video.polsatgo-1.2.zip

xxcriticxx commented 3 years ago

@mbebe polsat go dziala na starszym kodi 18.9 czy potrzebuje 19.1?

2021-08-24 18:47:31.304 T:4792   ERROR: C:\Users\***\AppData\Roaming\Kodi\addons\script.module.urllib3\lib\urllib3\connectionpool.py:1004: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
                                              InsecureRequestWarning,
2021-08-24 18:47:31.980 T:4792   ERROR: Previous line repeats 1 times.
2021-08-24 18:47:31.980 T:4792   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.KeyError'>
                                            Error Contents: 'result'
                                            Traceback (most recent call last):
                                              File "C:\Users\***\AppData\Roaming\Kodi\addons\plugin.video.polsatgo\main.py", line 1034, in <module>
                                                playVOD(exlink)
                                              File "C:\Users\***\AppData\Roaming\Kodi\addons\plugin.video.polsatgo\main.py", line 184, in playVOD
                                                dostep=checkAccess(id)
                                              File "C:\Users\***\AppData\Roaming\Kodi\addons\plugin.video.polsatgo\main.py", line 177, in checkAccess
                                                dostep=response['result'][-1]['access']['statusDescription']
                                            KeyError: 'result'
                                            -->End of Python script error report<---
hevet commented 3 years ago

U mnie na RPi4 z Kodi 18.9 dzia艂a 馃槈.

xxcriticxx commented 3 years ago

widze ze znowu pora na format

mbebe commented 3 years ago

@xxcriticxx a co probujesz odtworzyc?

hevet commented 3 years ago

@mbebe niestety przyk艂adowo nie dzia艂aj膮 niekt贸re pozycje w kategorii "Sport", np. "Kopalnia", "Badminton". Mo偶na wej艣膰 w te kategorie i poka偶e si臋 lista materia艂贸w, ale pr贸ba ich w艂膮czenia ko艅czy si臋 b艂臋dem.

xxcriticxx commented 3 years ago

@mbebe seriale kowalscy, swiat wedlug kiepskich, rolnicy, budolancy byle co z seriali nic mi nie otwiera

hevet commented 3 years ago

@mbebe u mnie teraz te pozycje w kategorii Sport dzia艂aj膮 :)

xxcriticxx commented 3 years ago

@mbebe clean 19.1 z polsatgo 1.1

https://paste.kodi.tv/ojitokatem

Mariusz89B commented 3 years ago

@mbebe Dziala, zobacz maila co tobie wyslalem. :)

hevet commented 3 years ago

W Kodi mam ustawione, by po sko艅czeniu jednego odcinka serialu czy innego programu w艂膮cza艂 si臋 nast臋pny. Dzia艂a to przyk艂adowo w dodatku Canal+, czy Youtube. Tak samo jest gdy wcisn臋 na klawiaturze by prze艂膮czy艂o si臋 na nast臋pny. W Polsat Go to nie dzia艂a, pytanie czy musi to by膰 jako艣 zaimplementowane w dodatku?

yrek150 commented 3 years ago

U mnie na 19.1 wczoraj pobiera艂a si臋 lista seriali, lista odcink贸w, a odpalenie czegokolwiek ko艅czy艂o si臋 b艂臋dem. Dzisiaj mam "working" ju偶 od 10 minut, ju偶 przy samej pr贸bie uruchomienia wtyczki... Edit: Efekt jak wy偶ej daje odpalenie wtyczki jako skr贸t z ekranu g艂贸wnego kodi. gdy zmienie element docelowy skt贸tu z "ekranu g艂贸wnego" wtyczki, na ekran "VOD", wtyczka sie uruchamia bez problemu. I odtwarzanie poszczeg贸lnych seriali dzia艂a bez problemu.

Dzisiaj znowu co艣 si臋 pokopa艂o, nic nie dzia艂a

faraonramzes commented 3 years ago

U mnie kodi 19 nie dzialaja niekt贸re seriale sprawdzone to fala zbrodni miodowe lata samo 偶ycie nie wiem jak reszta Polsat go

hevet commented 3 years ago

@mbebe uda艂oby si臋 naprawi膰 b艂膮d z wy偶ej wymienionymi serialami?

sk3383 commented 3 years ago

Android/ Kodi 19.1 nie dzia艂a odtwarzanie materia艂u video.

2021-09-06 10:16:49.263 T:13322 ERROR : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

  • NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: <class 'KeyError'> Error Contents: 'url' Traceback (most recent call last): File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py", line 293, in playCPGO PlayPolsatPseudo(str_url) File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py", line 312, in PlayPolsatPseudo play_item.setArt({'thumb': dane['img'], 'poster': dane['img'], 'banner': dane['img'], 'fanart': FANART}) KeyError: 'img'
                                               During handling of the above exception, another exception occurred:

                                               Traceback (most recent call last):
                                                 File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py", line 1208, in <module>
                                                   router(sys.argv[2][1:])
                                                 File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py", line 1186, in router
                                                   playVOD(exlink)
                                                 File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py", line 187, in playVOD
                                                   playCPGO(id,cpid=1)
                                                 File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py", line 296, in playCPGO
                                                   stream_url = mediaSources['url']
                                               KeyError: 'url'
                                               -->End of Python script error report<--
Kruk79 commented 3 years ago

Hej,

Jest mo偶liwo艣膰 dodania opcji aby wtyczka wy艣wietla艂a video w najlepszej jako艣ci po wybraniu video?

U mnie wszystko si臋 w艂膮cza w najni偶szej np 320p i musz臋 r臋cznie zmienia膰 z kodi.

Dzi臋ki

fingerr commented 3 years ago

Witam,

mam pytanie i pro艣b臋.

Jest szansa aby wtyczka PolsatGO by艂a zgodna z Kodi 18.9 na dekoderze z Enigm膮 (na razie nie ma 19.1 na t膮 platform臋)?

PlayerPL dzia艂a bez problemu, poni偶ej wycinek z loga:

2021-09-06 22:29:23.451 T:2507649840   ERROR: Previous line repeats 7 times.
2021-09-06 22:29:23.451 T:2507649840  NOTICE: [script.module.inputstreamhelper] Widevine update check was made on 2021-08-23 23:22
2021-09-06 22:29:23.597 T:3013020704  NOTICE: VideoPlayer::OpenFile: plugin://plugin.video.playermb/?name=Blaze+i+Mega+Maszyny+-+S02E01&moviescount=0&url=4646289&movie=True&image=https%3A%2F%2Fr-scale-1f.dcs.redcdn.pl%2Fscale%2Fo2%2Ftvn%2Fweb-content%2Fm%2Fp24%2Fi%2F02b1be0d48924c327124732726097157%2F927f0ee4-1778-4314-81d8-5d8640a7abbc.jpg%3Fsrcx%3D172%26srcy%3D128%26srcw%3D1740%26srch%3D979%26type%3D1%26srcmode%3D0%26quality%3D65%26dsth%3D177%26dstw%3D315&mode=playvid&page=1
2021-09-06 22:29:23.599 T:2452828976  NOTICE: Creating InputStream
2021-09-06 22:29:33.128 T:2452828976  NOTICE: Creating Demuxer
2021-09-06 22:29:33.129 T:2452828976  NOTICE: Opening stream: 1001 source: 256
2021-09-06 22:29:33.174 T:2452828976  NOTICE: Creating video codec with codec id: 27
2021-09-06 22:29:33.174 T:2452828976  NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: h264
2021-09-06 22:29:33.174 T:2452828976  NOTICE: Creating video thread
2021-09-06 22:29:33.175 T:2461242160  NOTICE: running thread: video_thread
2021-09-06 22:29:33.228 T:2452828976  NOTICE: Opening stream: 1002 source: 256
2021-09-06 22:29:33.285 T:2452828976  NOTICE: Finding audio codec for: 86018
2021-09-06 22:29:33.286 T:2452828976  NOTICE: CDVDAudioCodecFFmpeg::Open() Successful opened audio decoder aac
2021-09-06 22:29:33.286 T:2452828976  NOTICE: Creating audio thread
2021-09-06 22:29:33.286 T:2436043568  NOTICE: running thread: CVideoPlayerAudio::Process()
2021-09-06 22:29:33.722 T:2436043568  NOTICE: Creating audio stream (codec id: 86018, channels: 2, sample rate: 48000, no pass-through)
2021-09-06 22:29:33.755 T:2461242160  NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: h264
2021-09-06 22:29:33.940 T:3013020704  NOTICE: GLES: Selecting single pass rendering
2021-09-06 22:29:33.940 T:3013020704  NOTICE: GLES: Selecting YUV 2 RGB shader
2021-09-06 22:29:34.009 T:3013020704  NOTICE: GLES: Selecting single pass rendering
2021-09-06 22:29:34.375 T:2461242160  NOTICE: CDVDVideoCodecFFmpeg::CDropControl: calculated diff time: 40000

natomiast z PolsatGO nie dzia艂a, log:

2021-09-06 22:31:05.457 T:2410865456   ERROR: Previous line repeats 9 times.
2021-09-06 22:31:05.457 T:2410865456  NOTICE: [script.module.inputstreamhelper] Widevine update check was made on 2021-08-23 23:22
2021-09-06 22:31:05.616 T:3013020704  NOTICE: VideoPlayer::OpenFile: http://redirector.redefine.pl/vm2dash/f51c64f015611343acb261ed5f903ea4ee97d6b8/manifest.mpd
2021-09-06 22:31:05.620 T:2402472752  NOTICE: Creating InputStream
2021-09-06 22:31:12.692 T:2402472752   ERROR: AddOnLog: InputStream Adaptive: Unable to find license in JSON string
2021-09-06 22:31:12.692 T:2402472752   ERROR: AddOnLog: InputStream Adaptive: License update not successful (no keys)
2021-09-06 22:31:12.744 T:2402472752   ERROR: AddOnLog: InputStream Adaptive: Initialize failed (SingleSampleDecrypter)
2021-09-06 22:31:12.745 T:2402472752   ERROR: CVideoPlayer::OpenInputStream - error opening [http://redirector.redefine.pl/vm2dash/f51c64f015611343acb261ed5f903ea4ee97d6b8/manifest.mpd]
2021-09-06 22:31:12.745 T:2402472752  NOTICE: CVideoPlayer::OnExit()
2021-09-06 22:31:12.783 T:3013020704  NOTICE: CVideoPlayer::CloseFile()
2021-09-06 22:31:12.879 T:3013020704  NOTICE: VideoPlayer: waiting for threads to exit
2021-09-06 22:31:12.879 T:3013020704  NOTICE: VideoPlayer: finished waiting

Z g贸ry dzi臋kuj臋 za pomoc i wtyczki ratuj膮ce 偶ycie :) Finger.

Seico commented 3 years ago

U mnie nie dzia艂aj膮 niekt贸re seriale np. Fala zbrodni , Agentki , a dzia艂aj膮 np .Przyjaci贸艂ki , da艂o by rad臋 poprawi膰 to we wtyczce

DenDyGH commented 3 years ago

@mbebe czy m贸g艂by艣 poprawi膰 wy艣wietlanie grafik? Do "poster" jest przypisana "ikona" i zamiast obrazka odcinka (po lewej) wy艣wietla ikon臋 polsatu: https://i.imgur.com/wPUfObE.png Po zmianie z "ikona" na "image" pojawia si臋 obrazek odcinka (i dobrze) https://i.imgur.com/EkgUXcF.png (No chyba, 偶e API zwraca jeszcze jaki艣 lepszy obrazek kt贸ry mo偶na przypisa膰 do "poster".) Tyle, 偶e wtedy ikona w menu zmienia si臋 na inn膮 i jest przeskalowana (patrz lewa strona) https://i.imgur.com/yLDCGuL.png

I jeszcze przypomnienie. We wszystkich swoich wtyczkach przypisujesz: thumb, poster, banner i fanart, ale ci膮gle zapominasz o landscape co by艂o ju偶 wspominane tutaj: https://github.com/mbebe/blomqvist/issues/550

hevet commented 3 years ago

@DeGH dzia艂aj膮 Tobie Miodowe lata, bo u mnie przy pr贸bie wej艣cia wyskakuje b艂膮d dodatku?

DenDyGH commented 3 years ago

@DeGH dzia艂aj膮 Tobie Miodowe lata, bo u mnie przy pr贸bie wej艣cia wyskakuje b艂膮d dodatku?

Niestety nie dzia艂a.

hevet commented 3 years ago

@mbebe uda艂oby si臋 rozwi膮za膰 problemy z niedzia艂aniem w/w seriali?

mbebe commented 3 years ago

Poprawione w wersji 1.4. Dodalem do repo.

hevet commented 3 years ago

@mbebe u mnie dalej b艂膮d. Por贸wna艂em pliki main z wersji 1.3 i 1.4, wychodzi na to, 偶e s膮 identyczne. Da艂oby rad臋 wrzuci膰 poprawion膮 wersj臋?

mbebe commented 3 years ago

Sorry, pospieszylem sie. 1.5 w repo.

hevet commented 3 years ago

Super teraz dzia艂aj膮, problem jest tylko taki, 偶e przyk艂adowo gdy wyszukamy przez wyszukiwark臋 np. "Miodowe lata", to pr贸ba w艂膮czenia sko艅czy si臋 b艂臋dem, gdy wejdziemy normalnie przez kategori臋 Seriale to tu odtwarza poprawnie.

`ERROR : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

faraonramzes commented 3 years ago

tak potwierdzam ten problem z wyszukiwarka mozna by tez pomyslec o podzieleniu seriali na sezony by艂o by to wygodniejsze zw艂aszcza gdy jest duzo odcinkow

hevet commented 3 years ago

Z tym dzieleniem na sezony to jest ciekawa sprawa. Gdy wyszukasz przyk艂adowo serial "Pierwsza mi艂o艣膰" to tu b臋dzie podzia艂 na sezony, gdy wejdziesz przez kategorie Seriale, b臋d膮 wszystkie odcinki bez podzia艂u na sezony.

hevet commented 3 years ago

@mbebe uda艂oby si臋 jeszcze poprawi膰 wyszukiwark臋? Dzi臋ki

astar0th commented 3 years ago

podzielone seriale na sezony, a tak przy okazji chcia艂em podzi臋kowa膰 @mbebe, kawa艂 dobrej roboty

def vodList(id):

    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')

    items = []
    myperms = []
    ff = addon.getSetting('accgroups')
    lista=eval(ff)

    for l in lista:
        if 'sc:' in l:
            myperms.append(l)
        if 'oth:' in l:
            myperms.append(l)
        if 'loc:' in l:
            myperms.append(l)

    if 'getSubCategories' in id:
        id = id.split('|')[0]
        dane =stoken+'|'+sexpir+'|navigation|getSubCategories'
        authdata=getHmac(dane)

        data = {"id":1,"jsonrpc":"2.0","method":"getSubCategories","params":{"catid":int(id),"filters":[],"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":""}}

    else:
        dane =stoken+'|'+sexpir+'|navigation|getCategoryContentWithFlatNavigation'
        authdata=getHmac(dane)

        try:
            idc = int(id)
        except:
            idc = id
        data = {"id":1,"jsonrpc":"2.0","method":"getCategoryContentWithFlatNavigation","params":{"catid":idc,"offset":int(offse),"limit":50,"filters":[],"collection":{"type":"sortedby","name":"alfabetycznie","default":True,"value":"13"},"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":""}}

    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()

    mud='playVOD'
    folder=False
    isplay=False
    ss='0'

    try:

        aa = response['result']['results']
    except:
        aa = response['result']
    if not aa:
    return vodList(id)

    if 'keyCategoryId' in aa[0]:
        mud='vodlist'
        folder=True
        isplay=False
    try:
        otal = response['result']['total']
    except:
        otal = 0

    for i in aa:

        if 'keyCategoryId' in i:
        if i['keyCategoryId'] == i['id']:
                ss='1'

    item = {}

        for j in myperms:

            if i.get('thumbnails',None):
                item['img'] = i['thumbnails'][-1]['src'].encode('utf-8')
            else:
                item['img'] = None

            item['id'] = str(i['id'])+'|ss' if (ss == '1' )  else str(i['id'])  
        if (mud == 'vodlist'):
        item['id'] = item['id']+'|dod'                  

            try:
                item['title'] = i['title'].upper().encode('utf-8')
            except:
                item['title'] = i['name'].upper().encode('utf-8')
            item['plot'] = i['description'].encode('utf-8')
            items.append(item)

    dupes = []
    filter = []

    for entry in items:
        if not entry['id'] in dupes:
            filter.append(entry)
            dupes.append(entry['id'])
    items = filter
    itemz= len(items)

    for item in items:

        getid = str(item.get('id'))

    if 'dod' in getid:
            mud='vodlist'
            folder=True
            isplay=False

        if 'ss' in getid:       
                getid = getid.split('|')[0]+'|getSubCategories'
        else:
        getid = getid.split('|')[0]
        else:
            mud = 'playVOD'
            folder=False
            isplay=False

        contextmenu = []
        if mud =='playVOD':
            contextmenu.append(('[B][COLOR lightgreen]Dodaj do MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=DodajUsun&url=%s)'%str('vod_'+getid)))

        else:

            contextmenu.append(('[B][COLOR lightgreen]Dodaj do MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=DodajUsun&url=%s)'%str(getid)))

        add_item(name=item.get('title'), url=getid, mode=mud, image=item.get('img'), folder=folder, isPlayable=isplay, infoLabels={'plot':item.get('plot'),"title": item.get('title')}, contextmenu=contextmenu    , itemcount=itemz,FANART=FANART)

    if int(offse)+50<otal:
        add_item(name='Nast臋pna strona', url=id, mode='vodlist', image=RESOURCES+'nextpage.png', folder=True, isPlayable=False, infoLabels=None, contextmenu=None, itemcount=itemz,page=int(offse)+50,FANART=FANART)    

    xbmcplugin.endOfDirectory(addon_handle)
Mariusz89B commented 3 years ago

Podzielilem wyszukiwanie na sezony tez:

Tu skompilowana wtyczka: plugin.video.polsatgo-1.6.zip

def vodSzukaj(query):
    headers = {
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Connection': 'keep-alive',
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }
    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')

    items = []
    myperms = []

    ff = addon.getSetting('accgroups')
    lista=eval(ff)

    for l in lista:
        if 'sc:' in l:
            myperms.append(l)
        if 'oth:' in l:
            myperms.append(l)
        if 'loc:' in l:
            myperms.append(l)

    dane =stoken+'|'+sexpir+'|navigation|searchContent'
    authdata=getHmac(dane)

    data={"jsonrpc":"2.0","method":"searchContent","id":1,"params":{"query":query,"limit":50,"ua":uapg,"authData":{"sessionToken":authdata}}}

    data={
            "id": 1,
            "jsonrpc": "2.0",
            "method": "searchContent",
            "params": {
                "query": query,
                "limit": 50,
                "ua": uapg,
                "deviceId": {
                    "type": "other",
                    "value": devid
                },
                "userAgentData": {
                    "portal": "pg",
                    "deviceType": "pc",
                    "application": "firefox",
                    "player": "html",
                    "build": 1,
                    "os": "windows",
                    "osInfo": osinfo
                },
                "authData": {
                    "sessionToken": authdata
                },
                "clientId": clid
            }
        }

    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()

    mud='playVOD'
    folder=False
    isplay=False
    ss='0'

    try:
        aa = response['result']['results']
    except:
        aa = response['result']

    if not aa:
       return vodSzukaj(id)

    if 'keyCategoryId' in aa[0]:
        mud='vodlist'
        folder=True
        isplay=False
    try:
        otal = response['result']['total']
    except:
        otal = 0

    for i in aa:
        if 'keyCategoryId' in i:
            #mud='vodlist'
            #folder=True
            #isplay=False

            if i['keyCategoryId'] == i['id']:
                ss='1'

        else:
            mud='playVOD'
            folder=False
            isplay=False

        item = {}
        for j in myperms:
            if i.get('thumbnails',None):
                item['img'] = i['thumbnails'][-1]['src'].encode('utf-8')
            else:
                item['img'] = None

            item['id'] = str(i['id'])+'|ss' if (ss == '1' )  else str(i['id'])  
            if (mud == 'vodlist'):
                item['id'] = item['id']+'|dod'                  

            try:
                item['title'] = i['title'].upper().encode('utf-8')
            except:
                item['title'] = i['name'].upper().encode('utf-8')
            item['plot'] = i['description'].encode('utf-8')
            items.append(item)

    dupes = []
    filter = []
    for entry in items:
        if not entry['id'] in dupes:
            filter.append(entry)
            dupes.append(entry['id'])
    items = filter
    itemz= len(items)

    for item in items:
        idc = item.get('id')
        if 'dod' in idc:
            mud='vodlist'
            folder=True
            isplay=False

            #idc = idc.split('|')[0]+'|getSubCategories'
            if 'ss' in idc:       
                idc = idc.split('|')[0]+'|getSubCategories'
            else:
                idc = idc.split('|')[0]
        else:
            mud = 'playVOD'
            folder=False
            isplay=False

        contextmenu = []
        if mud =='playVOD':
            contextmenu.append(('[B][COLOR lightgreen]Dodaj do MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=DodajUsun&url=%s)'%str('vod_'+idc)))

        else:

            contextmenu.append(('[B][COLOR lightgreen]Dodaj do MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=DodajUsun&url=%s)'%str(idc)))

        add_item(name=item.get('title'), url=idc, mode=mud, image=item.get('img'), folder=folder, isPlayable=isplay, infoLabels=item, contextmenu=contextmenu, itemcount=itemz,FANART=FANART)    
    xbmcplugin.endOfDirectory(addon_handle)
hevet commented 3 years ago

Tutaj wersja z naprawionym wyszukiwaniem plugin.video.polsatgo.zip

Kawa艂ek kodu od @astar0th z tego postu https://github.com/mbebe/blomqvist/issues/597#issuecomment-922156048

hevet commented 3 years ago

W kategorii "LIVE" na Kodi 18.9 przy pr贸bie wej艣cia jest b艂膮d, w logu jest b艂膮d kodowania znaku w nazwie transmisja bezp艂atna (chodzi tu zapewne o liter臋 艂). Na Kodi 19.1 kategoria LIVE si臋 uruchamia ale zamiast polskich znak贸w wy艣wietlaj膮 si臋 jakie艣 ci膮gi znak贸w literowo-liczbowych screenshot00000 .

hevet commented 3 years ago

Wersja z poprawion膮 kategori膮 "LIVE", dzia艂a na Kodi 18 i 19. plugin.video.polsatgo_1.8.zip

DenDyGH commented 3 years ago

@mbebe w najnowszej wersji doda艂e艣 podzia艂 na sezony przez wyszukiwark臋 (czyli poprawka od @Mariusz89B), ale zapomnia艂e艣 o tej od @astar0th, czyli brakuje podzia艂u na sezony po wej艣ciu przez VOD > Seriale. Dodatkowo przyda艂oby si臋 aby sortowanie sz艂o od najnowszego odcinka, a nie od najstarszego. A najlepiej to da膰 wyb贸r :P

hevet commented 3 years ago

@DeGH z postu wy偶ej wgraj, jest tam dodana poprawka.

DenDyGH commented 3 years ago

Ja o tym wiem, ale chodzi o to by by艂o to w repo. Nie ka偶dy zagl膮da na githuba.

hevet commented 3 years ago

Dobrze by by艂o, @mbebe mo偶na prosi膰 o wrzucenie wersji 1.8 do repo?

astar0th commented 3 years ago

Wrzucam ca艂y main.py bo za du偶o drobnych zmian, w stosunku do ostatniej wersji -dodane sortowanie do wyboru -poprawiony sposob pobierania licencji - dzilaja najnowsze sporty i filmy -dzia艂a historia obejrzanych (VOD,szukanie,moja lista)- przydatne na niekt贸rych sk贸rach, np Eminence -materia艂y na "mojej liscie", podzielone na sezony

# -*- coding: UTF-8 -*-
import sys,re,os

try:
    # For Python 3.0 and later
   import urllib.parse as urlparse
except ImportError:
    # Fall back to Python 2's urllib2
    import urlparse

import requests
import xbmcgui
import xbmcplugin
import xbmcaddon
import xbmc, xbmcvfs

try:
    import http.cookiejar as cookielib
except ImportError:
    import  cookielib

try:
    from urllib.parse import urlencode, quote_plus, quote, unquote
except ImportError:
    from urllib import urlencode, quote_plus, quote, unquote

import random
import time

base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
params = dict(urlparse.parse_qsl(sys.argv[2][1:]))
addon = xbmcaddon.Addon(id='plugin.video.polsatgo')

PATH            = addon.getAddonInfo('path')
if sys.version_info >= (3,0,0):
    DATAPATH        = xbmcvfs.translatePath(addon.getAddonInfo('profile'))
else:
    DATAPATH        = xbmc.translatePath(addon.getAddonInfo('profile')).decode('utf-8')
RESOURCES       = PATH+'/resources/'
FANART=RESOURCES+'fanart.jpg'
ikona = RESOURCES+'../icon.png'

sys.path.append( os.path.join( RESOURCES, "lib" ) )

exlink = params.get('url', None)
name= params.get('title', None)
opisy= params.get('plot', None)
offse= params.get('page', None)
rys=params.get('image', None)

UA = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0'
osinfo = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"

uapg = "pg_pc_windows_firefox_html/1 (Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0)"
uapgwidevine = "pg_pc_windows_firefox_html/1 (Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0) (Windows 7; widevine=true)"
auth_url='https://b2c-www.redefine.pl/rpc/auth/'
navigate_url='https://b2c-www.redefine.pl/rpc/navigation/'
system_url = 'https://b2c-www.redefine.pl/rpc/system/'
user_url = 'https://b2c-www.redefine.pl/rpc/user_content/'
host = 'b2c-www.redefine.pl'
origin = 'https://polsatgo.pl'

clid = addon.getSetting('clientId')
devid = addon.getSetting('devid')

stoken = addon.getSetting('sesstoken')
sexpir = addon.getSetting('sessexpir')
skey = addon.getSetting('sesskey')

sortowaniev = addon.getSetting('sortowanieV')
if not sortowaniev:
    addon.setSetting('sortowanieV','"12"')
sortowanien = addon.getSetting('sortowanieN') if '12' not in sortowaniev else 'Ostatnio dodane'
sortowanien = 'Ostatnio dodane' if '12' in sortowaniev else 'Alfabetycznie'

def build_url(query):
    return base_url + '?' + urlencode(query)

def add_item(url, name, image, folder, mode,  isPlayable=True, infoLabels=False, FANART=None, contextmenu=None, itemcount=1, page=0):

    list_item = xbmcgui.ListItem(label=name)

    if isPlayable:
        list_item.setProperty("IsPlayable", 'true')
        contextMenuItems = []
        contextMenuItems.append(('Informacja', 'XBMC.Action(Info)'))
        list_item.addContextMenuItems(contextMenuItems, replaceItems=False)
    if contextmenu:
        out=contextmenu
        list_item.addContextMenuItems(out, replaceItems=True)

    if not infoLabels:
        infoLabels={'title': name,'plot':name}

    list_item.setInfo(type="video", infoLabels=infoLabels)

    FANART = FANART if FANART else image
    list_item.setArt({'thumb': image, 'poster': image, 'banner': image, 'fanart': FANART})
    xbmcplugin.addDirectoryItem(
        handle=addon_handle,
        url = build_url({'title':name,'mode': mode, 'url' : url, 'page' : page,'plot':infoLabels,'image':image}),
        listitem=list_item,
        isFolder=folder)

def PlayPolsat(stream_url,data):
    import inputstreamhelper

    PROTOCOL = 'mpd'
    DRM = 'com.widevine.alpha'
    LICENSE_URL = 'https://b2c-www.redefine.pl/rpc/drm/'
    is_helper = inputstreamhelper.Helper(PROTOCOL, drm=DRM)

    UAcp=  'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.9 Safari/537.36'

    dane=eval(opisy)
    if is_helper.check_inputstream():
        play_item = xbmcgui.ListItem(path=stream_url)#
        play_item.setInfo(type="Video", infoLabels={"title": dane['title'],'plot':dane['plot']})

        play_item.setArt({'thumb': rys, 'poster': rys, 'banner': rys, 'fanart': FANART})

        play_item.setMimeType('application/xml+dash')
        play_item.setContentLookup(False)
        if sys.version_info >= (3,0,0):
            play_item.setProperty('inputstream', is_helper.inputstream_addon)
        else:
            play_item.setProperty('inputstreamaddon', is_helper.inputstream_addon)
        play_item.setProperty("IsPlayable", "true")
        play_item.setProperty('inputstream.adaptive.manifest_type', PROTOCOL)
        play_item.setProperty('inputstream.adaptive.license_type', DRM)

        play_item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full')
        play_item.setProperty('inputstream.adaptive.stream_headers', 'Referer: %s'%(origin))
        play_item.setProperty('inputstream.adaptive.license_key',
                            LICENSE_URL + '|Content-Type=application%2Fjson&Referer=https://polsatgo.pl/&User-Agent=' + quote(UA) +
                            '|'+data+'|JBlicense')

        play_item.setProperty('inputstream.adaptive.license_flags', "persistent_storage")

    xbmcplugin.setResolvedUrl(addon_handle, True, listitem=play_item)

def checkAccess(id):
    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
        'Accept': 'application/json, text/plain, */*',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json; utf-8',
        'Origin': 'https://go.cyfrowypolsat.pl',
        'Connection': 'keep-alive',
    }

    dane =stoken+'|'+sexpir+'|navigation|getMedia'
    authdata=getHmac(dane)

    data={"jsonrpc":"2.0","method":"getMedia","id":1,"params":{"cpid":1,"mediaId":id,"ua":"cpgo_www/2015","authData":{"sessionToken":authdata}}}

    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()
    prod=response['result']['product']
    prodid=prod['id']
    prodtype=prod['type']
    prodstype=prod['subType']

    dane =stoken+'|'+sexpir+'|payments|checkProductsAccess'
    authdata=getHmac(dane)

    data={"jsonrpc":"2.0","method":"checkProductsAccess","id":1,"params":{"products":[{"id":prodid,"type":prodtype,"subType":prodstype}],"ua":"cpgo_www/2015","authData":{"sessionToken":authdata}}}
    response = requests.post('https://b2c-www.redefine.pl/rpc/payments/', headers=headers, json=data,timeout=15, verify=False).json()
    dostep=response['result'][-1]['access']['statusDescription']
    if 'no access' in dostep:
        return False
    else:
        return True

def playVOD(id):

    playCPGO(id,cpid=1)

def playCPGO(id,cpid=0):
    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')

    dane =stoken+'|'+sexpir+'|auth|getSession'

    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    authdata=getHmac(dane)

    data = {
            "id": 1,
            "jsonrpc": "2.0",
            "method": "getSession",
            "params": {
                "ua": uapg,
                "deviceId": {
                    "type": "other",
                    "value": devid
                },
                "userAgentData": {
                    "portal": "pg",
                    "deviceType": "pc",
                    "application": "firefox",
                    "player": "html",
                    "build": 1,
                    "os": "windows",
                    "osInfo": osinfo
                },
                "authData": {
                    "sessionToken": authdata
                },
                "clientId": ""}}

    response = requests.post(auth_url, headers=headers, json=data,timeout=15, verify=False).json()
    sesja=response['result']['session']

    sesstoken=sesja['id']
    sessexpir=str(sesja['keyExpirationTime'])
    sesskey=sesja['key']

    addon.setSetting('sesstoken', sesstoken)
    addon.setSetting('sessexpir', str(sessexpir))
    addon.setSetting('sesskey', sesskey)

    response = requests.post(auth_url, headers=headers, json=data,timeout=15, verify=False).json()
    sesja=response['result']['session']

    sesstoken=sesja['id']
    sessexpir=str(sesja['keyExpirationTime'])
    sesskey=sesja['key']

    addon.setSetting('sesstoken', sesstoken)
    addon.setSetting('sessexpir', str(sessexpir))
    addon.setSetting('sesskey', sesskey)

    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')

    dane =stoken+'|'+sexpir+'|navigation|prePlayData'
    authdata=getHmac(dane)

    data = {"jsonrpc":"2.0","id":1,"method":"prePlayData","params":{"ua":uapgwidevine,"userAgentData":{"deviceType":"pc","application":"firefox","os":"windows","build":2161400,"portal":"pg","player":"html","widevine":True},"cpid":cpid,"mediaId":id,"authData":{"sessionToken":authdata},"clientId":clid}}

    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()
    playback = response['result']['mediaItem']['playback']
    mediaid = playback['mediaId']['id']
    mediaSources = playback['mediaSources'][0]
    keyid = mediaSources['keyId']
    sourceid = mediaSources['id']

    try:
        cc=mediaSources['authorizationServices']['pseudo']
        dane =stoken+'|'+sexpir+'|drm|getPseudoLicense'
        authdata=getHmac(dane)
        devcid=devid.replace('-','')

        data={"jsonrpc":"2.0","id":1,"method":"getPseudoLicense","params":{"ua":"cpgo_www_html5/2","cpid":1,"mediaId":mediaid,"sourceId":sourceid,"deviceId":{"type":"other","value":devcid},"authData":{"sessionToken":authdata}}}
        response = requests.post('https://b2c-www.redefine.pl/rpc/drm/', headers=headers, json=data,timeout=15, verify=False).json()
        str_url=response['result']['url']

        PlayPolsatPseudo(str_url)
    except:

        stream_url = mediaSources['url']

        dane =stoken+'|'+sexpir+'|drm|getWidevineLicense'
        authdata=getHmac(dane)
        devcid=devid.replace('-','')

        data=quote('{"jsonrpc":"2.0","id":1,"method":"getWidevineLicense","params":{"userAgentData":{"deviceType":"pc","application":"firefox","os":"windows","build":2161400,"portal":"pg","player":"html","widevine":true},"cpid":%d,"mediaId":"'%cpid+mediaid+'","sourceId":"'+sourceid+'","keyId":"'+keyid+'","object":"b{SSM}","deviceId":{"type":"other","value":"'+devcid+'"},"ua":"pg_pc_windows_firefox_html/2161400","authData":{"sessionToken":"'+authdata+'"},"clientId":"'+clid+'"}}')

        PlayPolsat(stream_url,data)
    return

def PlayPolsatPseudo(str_url):
    dane=eval(opisy)
    play_item = xbmcgui.ListItem(path=str_url)#
    play_item.setInfo(type="Video", infoLabels={"title": dane['title'],'plot':dane['plot']})

    play_item.setArt({'thumb': rys, 'poster': rys, 'banner': rys, 'fanart': FANART})

    play_item.setContentLookup(False)
    play_item.setProperty("IsPlayable", "true")
    xbmcplugin.setResolvedUrl(addon_handle, True, listitem=play_item)

def loginCPgo():

    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    clid = addon.getSetting('clientId')
    devid = addon.getSetting('devid')

    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')
    skey = addon.getSetting('sesskey')

    def gen_hex_code(myrange=6):
        return ''.join([random.choice('0123456789abcdef') for x in range(myrange)])

    def ipla_system_id():
        myrand = gen_hex_code(10) + '-' + gen_hex_code(4) + '-' + gen_hex_code(4) + '-' + gen_hex_code(4) + '-' + gen_hex_code(12)
        return myrand

    def ipla_dev_id():
        myrand = gen_hex_code(32) + '_'
        return myrand

    if not clid and not devid:

        clientid=ipla_system_id()
        deviceid=ipla_dev_id()

        addon.setSetting('clientId', clientid)
        addon.setSetting('devid', deviceid)
        return loginCPgo()

    else:

        usernameCP = addon.getSetting('usernameCP')
        passwordCP = addon.getSetting('passwordCP')
        if usernameCP and passwordCP:

            data = {"id":1,"jsonrpc":"2.0","method":"login","params":{"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"clientId":"","authData":{"login":usernameCP,"password":passwordCP,"deviceId":{"type":"other","value":devid}}}}

            data = {
                    "id": 1,
                    "jsonrpc": "2.0",
                    "method": "login",
                    "params": {
                        "ua": uapg,
                        "deviceId": {
                            "type": "other",
                            "value": devid
                        },
                        "userAgentData": {
                            "portal": "pg",
                            "deviceType": "pc",
                            "application": "firefox",
                            "player": "html",
                            "build": 1,
                            "os": "windows",
                            "osInfo": osinfo
                        },
                        "clientId": "",
                        "authData": {
                            "login": usernameCP,
                            "password": passwordCP,
                            "deviceId": {
                                "type": "other",
                                "value": devid}}}
                    }

            response = requests.post(auth_url, headers=headers, json=data,timeout=15, verify=False).json()
            try:
                blad=response['error']
                if blad:
                    message=blad['message']
                    xbmcgui.Dialog().notification('[B]Logowanie[/B]', message,xbmcgui.NOTIFICATION_INFO, 6000)
                return False,False

            except:

                sesja=response['result']['session']

                sesstoken=sesja['id']
                sessexpir=str(sesja['keyExpirationTime'])
                sesskey=sesja['key']

                addon.setSetting('sesstoken', sesstoken)
                addon.setSetting('sessexpir', str(sessexpir))
                addon.setSetting('sesskey', sesskey)

                dane =sesstoken+'|'+sessexpir+'|auth|getSession'
                authdata=getHmac(dane)

                data = {
                        "id": 1,
                        "jsonrpc": "2.0",
                        "method": "getSession",
                        "params": {
                            "ua": uapg,
                            "deviceId": {
                                "type": "other",
                                "value": devid
                            },
                            "userAgentData": {
                                "portal": "pg",
                                "deviceType": "pc",
                                "application": "firefox",
                                "player": "html",
                                "build": 1,
                                "os": "windows",
                                "osInfo": osinfo
                            },
                            "authData": {
                                "sessionToken": authdata
                            },
                            "clientId": ""}}

                response = requests.post(auth_url, headers=headers, json=data,timeout=15, verify=False).json()
                sesja=response['result']['session']

                sesstoken=sesja['id']
                sessexpir=str(sesja['keyExpirationTime'])
                sesskey=sesja['key']

                addon.setSetting('sesstoken', sesstoken)
                addon.setSetting('sessexpir', str(sessexpir))
                addon.setSetting('sesskey', sesskey)
                accesgroup = response['result']['accessGroups']

                addon.setSetting('accgroups', str(accesgroup))

                dane =sesstoken+'|'+sessexpir+'|auth|getProfiles'
                authdata=getHmac(dane)
                data = {"id":1,"jsonrpc":"2.0","method":"getProfiles","params":{"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":""}}
                response = requests.post(auth_url, headers=headers, json=data,timeout=15, verify=False).json()
                nids = []
                for result in response['result']:
                    nids.append({'id':result['id'],'nazwa':result["name"],'img':result["avatarId"]})
                if len(nids)>1:
                    profile = [x.get('nazwa') for x in nids]
                    sel = xbmcgui.Dialog().select('Wybierz profil',profile)
                    if sel>-1:
                        id = nids[sel].get('id')
                        nazwa = nids[sel].get('nazwa')
                        avt = nids[sel].get('img')
                        profil = nazwa+'|'+id
                    else:
                        id = str(nids[0].get('id'))
                        nazwa = nids[0].get('nazwa')
                        avt = nids[sel].get('img')
                        profil = nazwa+'|'+id

                else:
                    id = str(nids[0].get('id'))
                    nazwa = nids[0].get('nazwa')
                    avt = nids[0].get('img')
                    profil = nazwa+'|'+id

                dane =sesstoken+'|'+sessexpir+'|auth|setSessionProfile'
                authdata=getHmac(dane)
                data = {"id":1,"jsonrpc":"2.0","method":"setSessionProfile","params":{"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":"","profileId":id}}
                response = requests.post(auth_url, headers=headers, json=data,timeout=15, verify=False).json()
                dane =sesstoken+'|'+sessexpir+'|auth|getSession'
                authdata=getHmac(dane)

                data = {"id":1,"jsonrpc":"2.0","method":"getSession","params":{"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":""}}

                response = requests.post(auth_url, headers=headers, json=data,timeout=15, verify=False).json()
                sesja=response['result']['session']

                sesstoken=sesja['id']
                sessexpir=str(sesja['keyExpirationTime'])
                sesskey=sesja['key']

                addon.setSetting('sesstoken', sesstoken)
                addon.setSetting('sessexpir', str(sessexpir))
                addon.setSetting('sesskey', sesskey)
                accesgroup = response['result']['accessGroups']

                addon.setSetting('accgroups', str(accesgroup))

                return True,profil

        else:
            xbmcgui.Dialog().notification('[B]Logowanie[/B]', 'B艂臋dne dane logowania.',xbmcgui.NOTIFICATION_INFO, 6000)
            return False,False

def home():
    logged,profil=loginCPgo()
    if logged:
        add_item(name='Zalogowany - %s'%(profil.split('|')[0]), url='', mode=' ', image='DefaultUser.png', folder=False, isPlayable=False,FANART=FANART)
        add_item(name='LIVE', url='', mode='live', image=ikona, folder=True, isPlayable=False,FANART=FANART)
        add_item(name='Telewizja', url='', mode='tvcpgo', image=ikona, folder=True, isPlayable=False,FANART=FANART)
        add_item(name='VOD', url='', mode='vodmain', image=ikona, folder=True, isPlayable=False,FANART=FANART)
        add_item(name='Moja lista', url='', mode='mojalista', image=ikona, folder=True, isPlayable=False,FANART=FANART)
    else:
        add_item('', '[B]Zaloguj[/B]','DefaultAddonService.png',False,'settings',False,FANART=FANART)
    xbmcplugin.endOfDirectory(addon_handle)

def newtime(self,ff):
    ff=re.sub(':\d+Z','',ff)

    import time
    import calendar
    dd=int(calendar.timegm(time.strptime(ff, '%Y-%m-%dT%H:%M')))
    format_date=datetime.datetime(*(time.localtime(dd)[0:6]))

    return dd,format_date

def live():
    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')

    items = []
    myperms = []
    ff = addon.getSetting('accgroups')
    lista=eval(ff)

    for l in lista:
        if 'sc:' in l or 'loc:' in l:
            myperms.append(l)

    dane =stoken+'|'+sexpir+'|navigation|getLiveChannels'
    authdata=getHmac(dane)

    data = {"id":1,"jsonrpc":"2.0","method":"getLiveChannels","params":{"filters":[],"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":clid}}

    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()
    aa=response['result']['results']
    for i in aa:
        item = {}

        channelperms = i['grantExpression'].split('+')
        channelperms = [w.replace('+plat:all', '') for w in channelperms]

        for j in myperms:

            if j in channelperms or u'transmisja bezp艂atna' in i['title']:
                item['img'] = i['thumbnails'][-1]['src'].encode('utf-8')
                item['id'] = i['id']

                z,data = newtime(i["publicationDate"])
                item['title'] = '%s - %s'%(data,i['title'].upper().encode('utf-8'))
                item['plot'] = i['category']['description'].encode('utf-8')
                items.append(item)
    dupes = []
    filter = []
    for entry in items:

        if not entry['id'] in dupes:
            filter.append(entry)
            dupes.append(entry['id'])

    items = filter
    items.sort(key=lambda x: x['title'])
    itemz= len(items)
    for item in items:
        opis=''
        add_item(name=item.get('title'), url=item.get('id'), mode='playCPGO', image=item.get('img'), folder=False, isPlayable=True, infoLabels={'title':item.get('title'),'plot':opis}, itemcount=itemz,FANART=FANART)

    xbmcplugin.endOfDirectory(addon_handle)

def tvmain():
    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')

    items = []
    myperms = []
    ff = addon.getSetting('accgroups')
    lista=eval(ff)

    for l in lista:
        if 'sc:' in l or 'loc:' in l:
            myperms.append(l)

    dane =stoken+'|'+sexpir+'|navigation|getTvChannels'
    authdata=getHmac(dane)

    data = {"id":1,"jsonrpc":"2.0","method":"getTvChannels","params":{"filters":[],"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":clid}}

    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()
    aa=response['result']['results']
    for i in aa:
        item = {}

        channelperms = i['grantExpression'].split('+')
        channelperms = [w.replace('+plat:all', '') for w in channelperms]

        for j in myperms:

            if j in channelperms or i['title']=='Polsat' or i['title']=='TV4':
                item['img'] = i['thumbnails'][-1]['src'].encode('utf-8')
                item['id'] = i['id']

                item['title'] = i['title'].upper().encode('utf-8')
                item['plot'] = i['category']['description'].encode('utf-8')
                items.append(item)
    dupes = []
    filter = []
    for entry in items:

        if not entry['id'] in dupes:
            filter.append(entry)
            dupes.append(entry['id'])

    addon.setSetting('kanaly', str(dupes))

    dups=getEpgs()
    items = filter
    itemz= len(items)
    for item in items:
        try:
            opis=dups[0][item.get('id')]
        except:
            opis=''
        add_item(name=item.get('title'), url=item.get('id'), mode='playCPGO', image=item.get('img'), folder=False, isPlayable=True, infoLabels={'title':item.get('title'),'plot':opis}, itemcount=itemz,FANART=FANART)

    xbmcplugin.endOfDirectory(addon_handle)

def newtime(ff):
    from datetime import datetime
    ff=re.sub(':\d+Z','',ff)
    dd=re.findall('T(\d+)',ff)[0]
    dzien=re.findall('(\d+)T',ff)[0]
    dd='{:>02d}'.format(int(dd)+2)
    if dd=='24':
        dd='00'
        dzien='{:>02d}'.format(int(dzien)+1)
    if dd=='25':
        dd='01'
        dzien='{:>02d}'.format(int(dzien)+1)
    ff=re.sub('(\d+)T(\d+)','%sT%s'%(dzien,int(dd)),ff)

    import time
    try:
        format_date=datetime.strptime(ff, '%Y-%m-%dT%H:%M')
    except TypeError:
        format_date=datetime(*(time.strptime(ff, '%Y-%m-%dT%H:%M')[0:6]))
    dd= int('{:0}'.format(int(time.mktime(format_date.timetuple()))))

    return dd,format_date

def getEpgs():
    kanaly = addon.getSetting('kanaly')
    kanaly=eval(kanaly)

    import datetime
    now = datetime.datetime.now()
    now2 = datetime.datetime.now()+ datetime.timedelta(days=1)
    aa1=now.strftime('%Y-%m-%dT%H:%M:%S') + ('.%03dZ' % (now.microsecond / 10000))
    aa=now2.strftime('%Y-%m-%dT%H:%M:%S') + ('.%03dZ' % (now.microsecond / 10000))

    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')

    dane =stoken+'|'+sexpir+'|navigation|getChannelsProgram'
    authdata=getHmac(dane)

    data={"jsonrpc":"2.0","method":"getChannelsProgram","id":1,"params":{"channelIds":kanaly,"fromDate":aa1,"toDate":aa,"ua":uapg,"authData":{"sessionToken":authdata}}}

    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()

    dupek=[]
    import datetime
    now = datetime.datetime.now()
    ab=now.strftime('%Y-%m-%dT%H:%M:%SZ')

    from datetime import datetime
    import time
    try:
        format_date=datetime.strptime(ab, '%Y-%m-%dT%H:%M:%SZ')
    except TypeError:
        format_date=datetime(*(time.strptime(ab, '%Y-%m-%dT%H:%M:%SZ')[0:6]))
    zz= int('{:0}'.format(int(time.mktime(format_date.timetuple()))))

    items={}
    for kanal in kanaly:

        el1=''
        if kanal in response['result']:
            dane=response['result'][kanal]
            for i in range(len(dane)):
                try:
                    nowy,format_date=newtime(dane[i]["startTime"])
                    nowy2,format_date2=newtime(dane[i+1]["startTime"])
                    trwa=nowy2-nowy
                    if nowy<zz and nowy+trwa>zz:
                        tyt=dane[i]["title"]
                        tyt2=dane[i]["genre"]
                        cc=re.sub(':\d+$','',str(format_date))
                        el1+='[COLOR khaki]'+cc+'[/COLOR] - '+tyt+' [COLOR violet]('+tyt2+')[/COLOR][CR]'
                    elif nowy>zz:
                        tyt=dane[i]["title"]
                        tyt2=dane[i]["genre"]
                        cc=re.sub(':\d+$','',str(format_date))
                        el1+='[COLOR khaki]'+cc+'[/COLOR] - '+tyt+' [COLOR violet]('+tyt2+')[/COLOR][CR]'

                except:
                    pass

        else:
            continue
        items[kanal]=el1
    dupek.append(items)

    return dupek

def vodmain():
    add_item(name='Szukaj', url='', mode='vodszukaj', image=RESOURCES+'search.png', folder=True, isPlayable=False,FANART=FANART)

    add_item(name='SERIALE', url='5024024', mode='vodlist', image='https://redirector.redefine.pl/iplatv/menu_icon_seriale.png', folder=True, isPlayable=False,FANART=FANART)
    add_item(name='SPORT', url='5024074', mode='vodlist', image='https://redirector.redefine.pl/iplatv/menu_icon_sport.png', folder=True, isPlayable=False,FANART=FANART)
    add_item(name='FILM', url='5024058', mode='vodlist', image='https://ipla-e3-18.pluscdn.pl/p/iplatv/gf/gfarpsbbncitbcsxze1artm3uf3i3jh8/film.png', folder=True, isPlayable=False,FANART=FANART)
    add_item(name='PROGRAMY', url='5024073', mode='vodlist', image='https://redirector.redefine.pl/iplatv/menu_icon_programy.png', folder=True, isPlayable=False,FANART=FANART)
    xbmcplugin.endOfDirectory(addon_handle)

def vodSzukaj(query):
    headers = {
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Connection': 'keep-alive',
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }
    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')

    items = []
    myperms = []

    ff = addon.getSetting('accgroups')
    lista=eval(ff)

    for l in lista:
        if 'sc:' in l:
            myperms.append(l)
        if 'oth:' in l:
            myperms.append(l)
        if 'loc:' in l:
            myperms.append(l)

    dane =stoken+'|'+sexpir+'|navigation|searchContent'
    authdata=getHmac(dane)

    data={"jsonrpc":"2.0","method":"searchContent","id":1,"params":{"query":query,"limit":50,"ua":uapg,"authData":{"sessionToken":authdata}}}

    data={
            "id": 1,
            "jsonrpc": "2.0",
            "method": "searchContent",
            "params": {
                "query": query,
                "limit": 50,
                "ua": uapg,
                "deviceId": {
                    "type": "other",
                    "value": devid
                },
                "userAgentData": {
                    "portal": "pg",
                    "deviceType": "pc",
                    "application": "firefox",
                    "player": "html",
                    "build": 1,
                    "os": "windows",
                    "osInfo": osinfo
                },
                "authData": {
                    "sessionToken": authdata
                },
                "clientId": clid
            }
        }

    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()

    mud='playVOD'
    folder=False
    isplay=False
    ss='0'

    try:
        aa = response['result']['results']
    except:
        aa = response['result']

    if not aa:
       return vodSzukaj(id)

    if 'keyCategoryId' in aa[0]:
        mud='vodlist'
        folder=True
        isplay=False
    try:
        otal = response['result']['total']
    except:
        otal = 0

    for i in aa:
        if 'keyCategoryId' in i:
            #mud='vodlist'
            #folder=True
            #isplay=False

            if i['keyCategoryId'] == i['id']:
                ss='1'

        else:
            mud='playVOD'
            folder=False
            isplay=False

        item = {}
        for j in myperms:
            if i.get('thumbnails',None):
                item['img'] = i['thumbnails'][-1]['src'].encode('utf-8')
            else:
                item['img'] = None

            item['id'] = str(i['id'])+'|ss' if (ss == '1' )  else str(i['id'])
            if (mud == 'vodlist'):
                item['id'] = item['id']+'|dod'

            try:
                item['title'] = i['title'].upper().encode('utf-8')
            except:
                item['title'] = i['name'].upper().encode('utf-8')
            item['plot'] = i['description'].encode('utf-8')
            items.append(item)

    dupes = []
    filter = []
    for entry in items:
        if not entry['id'] in dupes:
            filter.append(entry)
            dupes.append(entry['id'])
    items = filter
    itemz= len(items)

    for item in items:
        idc = item.get('id')
        if 'dod' in idc:
            mud='vodlist'
            folder=True
            isplay=False

            #idc = idc.split('|')[0]+'|getSubCategories'
            if 'ss' in idc:
                idc = idc.split('|')[0]+'|getSubCategories'
            else:
                idc = idc.split('|')[0]
        else:
            mud = 'playVOD'
            folder=False
            isplay=True

        contextmenu = []
        if mud =='playVOD':
            contextmenu.append(('[B][COLOR lightgreen]Dodaj do MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=DodajUsun&url=%s)'%str('vod_'+idc)))

        else:

            contextmenu.append(('[B][COLOR lightgreen]Dodaj do MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=DodajUsun&url=%s)'%str(idc)))

        add_item(name=item.get('title'), url=idc, mode=mud, image=item.get('img'), folder=folder, isPlayable=isplay, infoLabels={'title':item.get('title'),'plot':item.get('plot')}, contextmenu=contextmenu, itemcount=itemz,FANART=FANART)
    xbmcplugin.endOfDirectory(addon_handle)

def MojaLista():
    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')
    dane =stoken+'|'+sexpir+'|navigation|getFavoritesWithFlatNavigation'
    authdata=getHmac(dane)
    data = {"id":1,"jsonrpc":"2.0","method":"getFavoritesWithFlatNavigation","params":{"offset":0,"limit":50,"filters":[],"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":clid}}
    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()
    results = response.get('result',None).get('results',None)

    for r in results:
        object = r.get('object',None)
        try:
            tyt = (object.get('title',None)).upper().encode('utf-8')
        except:
            tyt = (object.get('name',None)).upper().encode('utf-8')

        description = (object.get('description',None)).encode('utf-8')
        imag = (object.get('thumbnails',None)[-1].get('src',None)).encode('utf-8')

        id = r.get('value',None)
        contextmenu = []

        if r.get('type',None) == 'category':
            mud = 'vodlist'
            folder = True
            isplay = False
            id = id+'|getSubCategories'
            contextmenu.append(('[B][COLOR red]Usu艅 z MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=Usun&url=category_%s)'%str(id)))
        else:
            mud = 'playVOD'
            folder=False
            isplay=False
            contextmenu.append(('[B][COLOR red]Usu艅 z MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=Usun&url=vod_%s)'%str(id)))
        add_item(name=tyt, url=id, mode=mud, image=imag, folder=folder, isPlayable=isplay, infoLabels={"title": tyt,'plot':description}, contextmenu=contextmenu,FANART=FANART)
    xbmcplugin.endOfDirectory(addon_handle)

def vodList(id):

#5024024 seriale
#5024074 sport
#5024058 filmy
#5024073 programy

    idss = ['5024024','5024074','5024058','5024073']
    if id in idss:
        add_item(url="s|"+id,name='Wy艣wietl materia艂y', image=ikona, mode='vodlist',folder=True, isPlayable=False, infoLabels=None, contextmenu=None,FANART=FANART)
        add_item(url=None,name='-    [COLOR lime]Sortowanie:[/COLOR] [B]'+sortowanien+'[/B]',image=ikona,mode='sortowanie',folder=True,isPlayable=False, infoLabels=None, contextmenu=None,FANART=FANART)
        xbmcplugin.endOfDirectory(addon_handle)
        return

    id__ = id.split('|')[0]
    if id__ == "s":
        id = id.split('|')[1]

    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    stoken = addon.getSetting('sesstoken')
    sexpir = addon.getSetting('sessexpir')

    items = []
    myperms = []
    ff = addon.getSetting('accgroups')
    lista=eval(ff)

    for l in lista:
        if 'sc:' in l:
            myperms.append(l)
        if 'oth:' in l:
            myperms.append(l)
        if 'loc:' in l:
            myperms.append(l)

    if 'getSubCategories' in id:
        id = id.split('|')[0]
        dane =stoken+'|'+sexpir+'|navigation|getSubCategories'
        authdata=getHmac(dane)

        data = {"id":1,"jsonrpc":"2.0","method":"getSubCategories","params":{"catid":int(id),"filters":[],"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":""}}

    else:
        dane =stoken+'|'+sexpir+'|navigation|getCategoryContentWithFlatNavigation'
        authdata=getHmac(dane)

        try:
            idc = int(id)
        except:
            idc = id
        data = {"id":1,"jsonrpc":"2.0","method":"getCategoryContentWithFlatNavigation","params":{"catid":idc,"offset":int(offse),"limit":50,"filters":[],"collection":{"type":"sortedby","name":eval(sortowaniev),"default":True,"value":eval(sortowaniev)},"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":""}}

    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()

    mud='playVOD'
    folder=False
    isplay=True
    ss='0'

    try:

        aa = response['result']['results']
    except:
        aa = response['result']
    if not aa:
        return vodList(id)

    if 'keyCategoryId' in aa[0]:
        mud='vodlist'
        folder=True
        isplay=False
    try:
        otal = response['result']['total']
    except:
        otal = 0

    for i in aa:

        if 'keyCategoryId' in i:
            if i['keyCategoryId'] == i['id']:
                ss='1'

        item = {}

        for j in myperms:

            if i.get('thumbnails',None):
                item['img'] = i['thumbnails'][-1]['src'].encode('utf-8')
            else:
                item['img'] = None

            item['id'] = str(i['id'])+'|ss' if (ss == '1' )  else str(i['id'])
            if (mud == 'vodlist'):
                item['id'] = item['id']+'|dod'

            try:
                item['title'] = i['title'].upper().encode('utf-8')
            except:
                item['title'] = i['name'].upper().encode('utf-8')
            item['plot'] = i['description'].encode('utf-8')
            items.append(item)

    dupes = []
    filter = []

    for entry in items:
        if not entry['id'] in dupes:
            filter.append(entry)
            dupes.append(entry['id'])
    items = filter
    itemz= len(items)

    for item in items:

        getid = str(item.get('id'))

        if 'dod' in getid:
            mud='vodlist'
            folder=True
            isplay=False

            if 'ss' in getid:
                getid = getid.split('|')[0]+'|getSubCategories'
            else:
                getid = getid.split('|')[0]
        else:
            mud = 'playVOD'
            folder=False
            isplay=True

        contextmenu = []
        if mud =='playVOD':
            contextmenu.append(('[B][COLOR lightgreen]Dodaj do MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=DodajUsun&url=%s)'%str('vod_'+getid)))

        else:

            contextmenu.append(('[B][COLOR lightgreen]Dodaj do MOJEJ LISTY[/B][/COLOR]', 'RunPlugin(plugin://plugin.video.polsatgo?mode=DodajUsun&url=%s)'%str(getid)))

        add_item(name=item.get('title'), url=getid, mode=mud, image=item.get('img'), folder=folder, isPlayable=isplay, infoLabels={'plot':item.get('plot'),"title": item.get('title')}, contextmenu=contextmenu    , itemcount=itemz,FANART=FANART)

    if int(offse)+50<otal:
        add_item(name='Nast臋pna strona', url="s|"+id, mode='vodlist', image=RESOURCES+'nextpage.png', folder=True, isPlayable=False, infoLabels=None, contextmenu=None, itemcount=itemz,page=int(offse)+50,FANART=FANART)

    xbmcplugin.endOfDirectory(addon_handle)

def getHmac(dane):
    skey = addon.getSetting('sesskey')
    import hmac
    import hashlib
    import binascii
    import base64
    from hashlib import sha256
    ssdalej=dane
    import base64

    def base64_decode(s):
        """Add missing padding to string and return the decoded base64 string."""
        #log = logging.getLogger()
        s = str(s).strip()
        try:
            return base64.b64decode(s)
        except TypeError:
            padding = len(s) % 4
            if padding == 1:
                #log.error("Invalid base64 string: {}".format(s))
                return ''
            elif padding == 2:
                s += b'=='
            elif padding == 3:
                s += b'='
            return base64.b64decode(s)
    secretAccessKey = base64_decode(skey.replace('-','+').replace('_','/'))

    auth = hmac.new(secretAccessKey, ssdalej.encode("ascii"), sha256)
    vv= base64.b64encode(bytes(auth.digest())).decode("ascii")

    aa=vv
    bb=ssdalej+'|'+aa.replace('+','-').replace('/','_')
    return bb

def Usun(id):

    kateg,id = id.split('_')
    typ = {"type":kateg,"value":id}

    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    dane =stoken+'|'+sexpir+'|user_content|deleteFromFavorites'
    authdata=getHmac(dane)

    data = {"id":1,"jsonrpc":"2.0","method":"deleteFromFavorites","params":{"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":clid,"favorite":typ}}

    response = requests.post(user_url, headers=headers, json=data,timeout=15, verify=False).json()
    xbmcgui.Dialog().notification('[B]Info[/B]', 'Usuni臋to z MOJEJ LISTY' ,xbmcgui.NOTIFICATION_INFO, 6000)
    xbmc.executebuiltin("Container.Update({0}?mode=mojalista,replace)".format(sys.argv[0]))

def dodajusun(id):

    kateg = 'category'

    if 'vod' in id:
        kateg,id = id.split('_')
    typ = {"type":kateg,"value":id}

    headers = {
        'Host': host,
        'User-Agent': UA,
        'Accept': 'application/json',
        'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
        'Content-Type': 'application/json;charset=utf-8',
        'Origin': origin,
        'Referer': origin,
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
    }

    dane =stoken+'|'+sexpir+'|user_content|addToFavorites'
    authdata=getHmac(dane)

    data = {"id":1,"jsonrpc":"2.0","method":"addToFavorites","params":{"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":clid,"favorite":typ}}

    response = requests.post(user_url, headers=headers, json=data,timeout=15, verify=False).json()
    dane =stoken+'|'+sexpir+'|navigation|getFavoritesWithFlatNavigation'
    authdata=getHmac(dane)
    data = {"id":1,"jsonrpc":"2.0","method":"getFavoritesWithFlatNavigation","params":{"offset":0,"limit":40,"filters":[],"ua":uapg,"deviceId":{"type":"other","value":devid},"userAgentData":{"portal":"pg","deviceType":"pc","application":"firefox","player":"html","build":1,"os":"windows","osInfo":osinfo},"authData":{"sessionToken":authdata},"clientId":clid}}
    response = requests.post(navigate_url, headers=headers, json=data,timeout=15, verify=False).json()

    results = response.get('result',None).get('results',None)
    for r in results:
        if r.get('value',None) == id:
            komunikat = 'DODANE DO LISTY'
            break
        else:
            continue
    xbmcgui.Dialog().notification('[B]Info[/B]', komunikat,xbmcgui.NOTIFICATION_INFO, 6000)

    return

def PLchar(char):
    if type(char) is not str:
        char=char.encode('utf-8')
    char = char.replace('\\u0105','\xc4\x85').replace('\\u0104','\xc4\x84')
    char = char.replace('\\u0107','\xc4\x87').replace('\\u0106','\xc4\x86')
    char = char.replace('\\u0119','\xc4\x99').replace('\\u0118','\xc4\x98')
    char = char.replace('\\u0142','\xc5\x82').replace('\\u0141','\xc5\x81')
    char = char.replace('\\u0144','\xc5\x84').replace('\\u0144','\xc5\x83')
    char = char.replace('\\u00f3','\xc3\xb3').replace('\\u00d3','\xc3\x93')
    char = char.replace('\\u015b','\xc5\x9b').replace('\\u015a','\xc5\x9a')
    char = char.replace('\\u017a','\xc5\xba').replace('\\u0179','\xc5\xb9')
    char = char.replace('\\u017c','\xc5\xbc').replace('\\u017b','\xc5\xbb')
    char = char.replace('&#8217;',"'")
    char = char.replace('&#8211;',"-")
    char = char.replace('&#8230;',"...")
    char = char.replace('&#8222;','"').replace('&#8221;','"')
    char = char.replace('[&hellip;]',"...")
    char = char.replace('&#038;',"&")
    char = char.replace('&#039;',"'")
    char = char.replace('&quot;','"')
    char = char.replace('&nbsp;',".").replace('&amp;','&')
    return char

def router(paramstring):
    args = dict(urlparse.parse_qsl(paramstring))

    if args:
        mode = args.get('mode', None)

        if mode == 'playCPGO':
            playCPGO(exlink)
        elif mode == 'live':
            live()
        elif mode == 'tvcpgo':
            tvmain()
        elif mode == 'vodmain':
            vodmain()
        elif mode == 'vodlist':
            vodList(exlink)

        elif mode == 'playVOD':
            playVOD(exlink)
        elif mode == 'ListVODsubCateg':
            ListVODsubCateg (exlink)
        elif 'sortowanie' == mode:

            label =["Ostatnio dodane","Alfabetycznie"]
            value =["12","13"]

            msg = 'Spos贸b sortowania'

            sel = xbmcgui.Dialog().select('Wybierz '+msg,label)

            sel = sel if sel>-1 else quit()

            v = '"%s"'%(value[sel])
            n = '%s'%(label[sel])

            addon.setSetting(mode+'V',v)
            addon.setSetting(mode+'N',n)
            xbmc.executebuiltin("Container.Refresh")
        elif mode == 'vodszukaj':
            query = xbmcgui.Dialog().input(u'Szukaj, Podaj tytu艂...', type=xbmcgui.INPUT_ALPHANUM)
            if query:
                vodSzukaj(query)

        elif mode == 'settings':
            addon.openSettings()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode =='DodajUsun':
            dodajusun(exlink)
        elif mode =='Usun':
            Usun(exlink)
        elif mode == 'mojalista':
            MojaLista()

    else:
        home()

if __name__ == '__main__':
    router(sys.argv[2][1:])
xxcriticxx commented 3 years ago

@astar0th ogl膮danie przez VPN dasz rade poprawic?

notoco commented 3 years ago

@mbebe - udost臋pnij 藕r贸d艂a 偶eby mo偶na by艂o normalnie pracowa膰...

mbebe commented 3 years ago

Na razie dodalem kilka. https://github.com/mbebe/blomqvist/tree/master/srcs

hevet commented 3 years ago

@astar0th dzisiaj zauwa偶y艂em, b艂膮d w wyszukiwarce. Przyk艂adowo gdy wpiszemy w wyszukiwarce s艂owo "POLSAT" i spr贸bujemy w艂膮czy膰 po wyszukiwaniu "POLSAT MUSIC" ujrzymy taki komunikat screenshot000 Gdy spr贸bujemy w艂膮czy膰 "POLSAT MUSIC" przez wej艣cie w VOD - PROGRAMY ujrzymy normalnie list臋 pozycji do odtworzenia.

astar0th commented 3 years ago

@astar0th dzisiaj zauwa偶y艂em, b艂膮d w wyszukiwarce. Przyk艂adowo gdy wpiszemy w wyszukiwarce s艂owo "POLSAT" i spr贸bujemy w艂膮czy膰 po wyszukiwaniu "POLSAT MUSIC" ujrzymy taki komunikat screenshot000 Gdy spr贸bujemy w艂膮czy膰 "POLSAT MUSIC" przez wej艣cie w VOD - PROGRAMY ujrzymy normalnie list臋 pozycji do odtworzenia.

poprawione wyszukiwanie https://github.com/astar0th/blomqvist_srcs/blob/main/srcs/plugin.video.polsatgo/main.py

hevet commented 3 years ago

@astar0th podzi臋kowania za szybk膮 poprawk臋 馃檪

astar0th commented 3 years ago

@mbebe wersja 1.8 to 1.7

Kruk79 commented 3 years ago

Czy wtyczka dalej dzia艂a? Jakikolwiek program wywala b艂膮d ze nie mo偶na otworzy膰 materia艂u.

hevet commented 3 years ago

@Kruk79 dzia艂a bez problemu.

Kruk79 commented 3 years ago

Hm.. a mo偶e kto艣 potwierdzi膰 kto u偶ywa VPNa? Zar贸wno aplikacja PolsatGo jak i wtyczka w Kodi nie dzia艂a z w艂膮czonym VPN. Sprawdza艂em dwa r贸偶ne VPN. Bez VPN nie dzia艂a w og贸le.

xxcriticxx commented 3 years ago

@Kruk79 potwierdzam PolsatGo nie dziala przez VPN z zagranicy. Dawno prosilem o naprawe ale kazdy zajenty.

tutaj jest jeszcze jedno potwierdzenie: https://github.com/mbebe/blomqvist/issues/619

moze @mbebe cos w koncu zrobi z tym fantem

Kruk79 commented 3 years ago

Wycinek z loga dla problemu z VPN:

`2021-10-28 22:48:56.416 T:19901 ERROR : /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.module.urllib3/lib/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'b2c-www.redefine.pl'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings warnings.warn(

2021-10-28 22:48:59.242 T:19901 INFO : Skipped 4 duplicate messages.. 2021-10-28 22:48:59.242 T:19901 INFO : CPythonInvoker(4, /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py): script successfully run 2021-10-28 22:48:59.689 T:19901 INFO : Python interpreter stopped 2021-10-28 22:49:01.746 T:20035 INFO : initializing python engine. 2021-10-28 22:49:04.898 T:19875 INFO : CPythonInvoker(3, /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/service.xbmc.versioncheck/resources/lib/runner.py): script successfully run 2021-10-28 22:49:05.372 T:19875 INFO : Python interpreter stopped 2021-10-28 22:49:05.790 T:20035 ERROR : /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.module.urllib3/lib/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'b2c-www.redefine.pl'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings warnings.warn(

2021-10-28 22:49:06.138 T:20035 INFO : CPythonInvoker(5, /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py): script successfully run 2021-10-28 22:49:06.635 T:20035 INFO : Python interpreter stopped 2021-10-28 22:49:08.072 T:20238 INFO : initializing python engine. 2021-10-28 22:49:10.027 T:20238 ERROR : /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.module.urllib3/lib/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'b2c-www.redefine.pl'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings warnings.warn(

2021-10-28 22:49:11.022 T:20238 INFO : CPythonInvoker(6, /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py): script successfully run 2021-10-28 22:49:11.536 T:20238 INFO : Python interpreter stopped 2021-10-28 22:49:14.041 T:20268 INFO : initializing python engine. 2021-10-28 22:49:15.755 T:20268 ERROR : /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.module.urllib3/lib/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'b2c-www.redefine.pl'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings warnings.warn(

2021-10-28 22:49:17.415 T:20268 INFO : Skipped 2 duplicate messages.. 2021-10-28 22:49:17.415 T:20268 INFO : CPythonInvoker(7, /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.polsatgo/main.py): script successfully run 2021-10-28 22:49:17.498 T:19830 INFO : VideoPlayer::OpenFile: http://redirector.redefine.pl/vm2dash/b4b12eeed6a6efa3b757355cd4a5a62d8c4397eb/manifest.mpd 2021-10-28 22:49:17.503 T:20273 INFO : Creating InputStream 2021-10-28 22:49:17.550 T:20273 INFO : AddOnLog: inputstream.adaptive: SetVideoResolution (1920 x 1080) 2021-10-28 22:49:17.565 T:20273 ERROR : GetDirectory - Error getting /data/user/0/org.xbmc.kodi/cache/apk/assets/addons/inputstream.adaptive/ 2021-10-28 22:49:17.636 T:20273 ERROR : AddOnLog: inputstream.adaptive: Key system request: com.widevine.alpha 2021-10-28 22:49:17.857 T:20268 INFO : Python interpreter stopped 2021-10-28 22:49:18.476 T:20273 INFO : AddOnLog: inputstream.adaptive: Successfully parsed manifest file. #Periods: 1, #Streams in first period: 3, Type: VOD, Download speed: 3961674.0346 Bytes/s 2021-10-28 22:49:19.091 T:20273 ERROR : AddOnLog: inputstream.adaptive: Unable to find license in JSON string 2021-10-28 22:49:19.093 T:20273 ERROR : AddOnLog: inputstream.adaptive: Initialize failed (SingleSampleDecrypter) 2021-10-28 22:49:19.096 T:20273 ERROR : CVideoPlayer::OpenInputStream - error opening [http://redirector.redefine.pl/vm2dash/b4b12eeed6a6efa3b757355cd4a5a62d8c4397eb/manifest.mpd] 2021-10-28 22:49:19.096 T:20273 INFO : CVideoPlayer::OnExit()`