• Vítejte na XBMC-Kodi.cz
  • Česko-slovenská komunita fanoušků XBMC/Kodi
Vítejte návštevníku! Přihlášení Registrace


Hodnocení tématu:
  • 6 Hlas(ů) - 2.33 Průměr
  • 1
  • 2
  • 3
  • 4
  • 5
Playlist OrangeTV Addon
#37
v o2tvgo.py přidal výběr kodeku "videoCodec": "H264", změnil 'client_id'. po úpravě stahuje pc verzi streamu.


Kód:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Wrapper pro O2TV Go
"""

import requests

__author__ = "Štěpán Ort"
__license__ = "MIT"
__version__ = "1.1.8"
__email__ = "stepanort@gmail.com"

_COMMON_HEADERS = {"X-NanguTv-App-Version": "Android#1.2.9",
                  "X-NanguTv-Device-Name": "Nexus 7",
                  "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.1.1; Nexus 7 Build/LMY47V)",
                  "Accept-Encoding": "gzip",
                  "Connection": "Keep-Alive"}


def _to_string(text):
   if type(text).__name__ == 'unicode':
       output = text.encode('utf-8')
   else:
       output = str(text)
   return output


# Kanál


class LiveChannel:

   # JiRo - doplněn parametr kvality
   def __init__(self, o2tv, channel_key, name, logo_url, weight, quality):
       self._o2tv = o2tv
       self.channel_key = channel_key
       self.name = name
       self.weight = weight
       self.logo_url = logo_url
       self.quality = quality  # doplněn parametr kvality

   def url(self):
       if not self._o2tv.access_token:
           self._o2tv.refresh_access_token()
       access_token = self._o2tv.access_token
       if not self._o2tv.subscription_code:
           self._o2tv.refresh_configuration()
       subscription_code = self._o2tv.subscription_code
       playlist = None
       while access_token:
           params = {"serviceType": "LIVE_TV",
                     "subscriptionCode": subscription_code,
                     "channelKey": self.channel_key,
                     "deviceType": "PC",
                     "videoCodec": "H264",
                     "streamingProtocol": "HLS"}  # JiRo - doplněn parametr kvality
           headers = _COMMON_HEADERS
           cookies = {"access_token": access_token,
                      "deviceId": self._o2tv.device_id}
           req = requests.get('http://app01.gtm.orange.sk/sws/server/streaming/uris.json',
                              params=params, headers=headers, cookies=cookies)
           json_data = req.json()
           access_token = None
           if 'statusMessage' in json_data:
               status = json_data['statusMessage']
               if status == 'bad-credentials':
                   access_token = self._o2tv.refresh_access_token()
               elif status == 'channel.not-found':
                   raise ChannelIsNotBroadcastingError()
               else:
                   raise Exception(status)
           else:
               # Pavuucek: Pokus o vynucení HD kvality
               playlist = ""
               # pro kvalitu STB nebo PC se pokusíme vybrat HD adresu.
               # když není k dispozici, tak první v seznamu
               for uris in json_data["uris"]:
                   if self.quality == "STB" or self.quality == "PC":
                       if uris["resolution"] == "HD" and playlist == "":
                           playlist = uris["uri"]
                   else:
                       # pro ostatní vracíme SD adresu
                       if uris["resolution"] == "SD" and playlist == "":
                           playlist = uris["uri"]
               # playlist nebyl přiřazený, takže první adresa v seznamu
               if playlist == "":
                   playlist = json_data["uris"][0]["uri"]
       return playlist


class ChannelIsNotBroadcastingError(BaseException):
   pass


class AuthenticationError(BaseException):
   pass


class TooManyDevicesError(BaseException):
   pass


# JiRo - doplněna kontrola zaplacené služby
class NoPurchasedServiceError(BaseException):
   pass


class O2TVGO:

   def __init__(self, device_id, username, password, quality, log_function=None):  # JiRo - doplněn parametr kvality
       self.username = username
       self.password = password
       self._live_channels = {}
       self.access_token = None
       self.subscription_code = None
       self.locality = None
       self.offer = None
       self.device_id = device_id
       self.quality = quality  # JiRo - doplněn parametr kvality
       self.log_function = log_function

   def _log(self, message):
       if self.log_function:
           self.log_function(message)
   def get_access_token_password(self):
       self._log('Getting Token via password...')
       if not self.username or not self.password:
           raise AuthenticationError()
       headers = _COMMON_HEADERS
       headers["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8"
      data = {'grant_type': 'password',
              'client_id': 'orangesk-webportal',
              'client_secret': 'e76f5f4d9295eaaa765c24844e11d559',
              'isp_id': '5',
              'username': self.username,
              'password': self.password,
              'platform_id': 'b0af5c7d6e17f24259a20cf60e069c22',
              'custom': 'orange-webportal-new',
'response_type': 'token'
}
       req = requests.post('https://oauth01.gtm.orange.sk/oauth/token',
                           data=data, headers=headers, verify=False)
       j = req.json()
       if 'error' in j:
           error = j['error']
           if error == 'authentication-failed':
               self._log('Authentication Error')
               return None
           else:
               raise Exception(error)
       self.access_token = j["access_token"]
       self.expires_in = j["expires_in"]
       self._log('Token OK')
       return self.access_token

   def refresh_access_token(self):
       if not self.access_token:
           self.get_access_token_password()
       if not self.access_token:
           self._log('Authentication Error (failed to get token)')
           raise AuthenticationError()
       return self.access_token

   def refresh_configuration(self):
       if not self.access_token:
           self.refresh_access_token()
       access_token = self.access_token
       headers = _COMMON_HEADERS
       cookies = {"access_token": access_token, "deviceId": self.device_id}
       req = requests.get(
           'https://app01.gtm.orange.sk/sws//subscription/settings/subscription-configuration.json', headers=headers,
           cookies=cookies)
       j = req.json()
       if 'errorMessage' in j:
           error_message = j['errorMessage']
           status_message = j['statusMessage']
           # JiRo - změna z 'unauthorized-device' na 'devices-limit-exceeded'
           if status_message == 'devices-limit-exceeded':
               raise TooManyDevicesError()
           else:
               raise Exception(error_message)
       self.subscription_code = _to_string(j["subscription"])
       self.offer = j["billingParams"]["offers"]
       self.tariff = j["billingParams"]["tariff"]
       self.locality = j["locality"]

   def live_channels(self):
       if not self.access_token:
           self.refresh_access_token()
       access_token = self.access_token
       if not self.offer:
           self.refresh_configuration()
       offer = self.offer
       if not self.tariff:
           self.refresh_configuration()
       tariff = self.tariff
       if not self.locality:
           self.refresh_configuration()
       locality = self.locality
       quality = self.quality  # JiRo - doplněn parametr kvality
       if len(self._live_channels) == 0:
           headers = _COMMON_HEADERS
           cookies = {"access_token": access_token,
                      "deviceId": self.device_id}
           params = {"locality": self.locality,
                     "tariff": self.tariff ,
                     "isp": "5",
 "imageSize": "LARGE",
                     "language": "slo",
                     "deviceType": "PC",
                     "liveTvStreamingProtocol": "HLS",
                     "offer": self.offer}  # doplněn parametr kvality
           req = requests.get('http://app01.gtm.orange.sk/sws/server/tv/channels.json',
                              params=params, headers=headers, cookies=cookies)
           j = req.json()
           purchased_channels = j['purchasedChannels']
           if len(purchased_channels) == 0:  # JiRo - doplněna kontrola zaplacené služby
               raise NoPurchasedServiceError()  # JiRo - doplněna kontrola zaplacené služby
           items = j['channels']
           for channel_id, item in items.iteritems():
               if channel_id in purchased_channels:
                   live = item['liveTvPlayable']
                   if live:
                       channel_key = _to_string(item['channelKey'])
                       logo = _to_string(item['logo'])
                       if not logo.startswith('http://'):
                           logo = 'http://app01.gtm.orange.sk/' + logo
                       name = _to_string(item['channelName'])
                       weight = item['weight']
                       self._live_channels[channel_key] = LiveChannel(
                           self, channel_key, name, logo, weight, quality)  # doplněn parametr kvality
           done = False
           offset = 0    
                         
       return self._live_channels
 
Citovat
  


Příspěvků v tématu
Playlist OrangeTV Addon - od johnyzh94 - 08.5.2019, 20:58
RE: Playlist OrangeTV Addon - od johnyzh94 - 09.5.2019, 18:21
RE: Playlist OrangeTV Addon - od Client - 09.5.2019, 18:37
RE: Playlist OrangeTV Addon - od nizo11 - 09.5.2019, 19:23
RE: Playlist OrangeTV Addon - od johnyzh94 - 09.5.2019, 20:52
RE: Playlist OrangeTV Addon - od Client - 09.5.2019, 21:14
RE: Playlist OrangeTV Addon - od johnyzh94 - 09.5.2019, 21:49
RE: Playlist OrangeTV Addon - od Client - 09.5.2019, 22:12
RE: Playlist OrangeTV Addon - od johnyzh94 - 09.5.2019, 22:19
RE: Playlist OrangeTV Addon - od Client - 09.5.2019, 22:46
RE: Playlist OrangeTV Addon - od johnyzh94 - 09.5.2019, 23:02
RE: Playlist OrangeTV Addon - od otava5 - 12.5.2019, 10:38
RE: Playlist OrangeTV Addon - od Client - 12.5.2019, 13:34
RE: Playlist OrangeTV Addon - od johnyzh94 - 12.5.2019, 14:21
RE: Playlist OrangeTV Addon - od ju-ro - 23.5.2020, 15:21
RE: Playlist OrangeTV Addon - od otava5 - 10.5.2019, 8:22
RE: Playlist OrangeTV Addon - od Mano - 10.5.2019, 9:41
RE: Playlist OrangeTV Addon - od johnyzh94 - 10.5.2019, 9:49
RE: Playlist OrangeTV Addon - od Mano - 10.5.2019, 10:01
RE: Playlist OrangeTV Addon - od Mano - 10.5.2019, 13:09
RE: Playlist OrangeTV Addon - od johnyzh94 - 10.5.2019, 14:15
RE: Playlist OrangeTV Addon - od Client - 10.5.2019, 18:49
RE: Playlist OrangeTV Addon - od otava5 - 10.5.2019, 13:31
RE: Playlist OrangeTV Addon - od Mano - 10.5.2019, 18:52
RE: Playlist OrangeTV Addon - od Client - 10.5.2019, 19:22
RE: Playlist OrangeTV Addon - od johnyzh94 - 10.5.2019, 19:46
RE: Playlist OrangeTV Addon - od Client - 10.5.2019, 20:12
RE: Playlist OrangeTV Addon - od johnyzh94 - 10.5.2019, 20:55
RE: Playlist OrangeTV Addon - od otava5 - 11.5.2019, 7:17
RE: Playlist OrangeTV Addon - od Client - 11.5.2019, 8:07
RE: Playlist OrangeTV Addon - od otava5 - 11.5.2019, 9:44
RE: Playlist OrangeTV Addon - od Client - 11.5.2019, 10:04
RE: Playlist OrangeTV Addon - od Client - 13.5.2019, 0:03
RE: Playlist OrangeTV Addon - od johnyzh94 - 13.5.2019, 0:13
RE: Playlist OrangeTV Addon - od jastrab - 14.5.2019, 12:51
RE: Playlist OrangeTV Addon - od marhycz - 19.5.2019, 13:01
RE: Playlist OrangeTV Addon - od jastrab - 20.5.2019, 10:08
RE: Playlist OrangeTV Addon - od johnyzh94 - 14.5.2019, 13:07
RE: Playlist OrangeTV Addon - od eta - 17.5.2019, 17:03
RE: Playlist OrangeTV Addon - od johnyzh94 - 17.5.2019, 19:04
RE: Playlist OrangeTV Addon - od Client - 17.5.2019, 20:00
RE: Playlist OrangeTV Addon - od eta - 19.5.2019, 8:04
RE: Playlist OrangeTV Addon - od Client - 19.5.2019, 9:01
RE: Playlist OrangeTV Addon - od eta - 19.5.2019, 10:27
RE: Playlist OrangeTV Addon - od Client - 19.5.2019, 16:32
RE: Playlist OrangeTV Addon - od eta - 20.5.2019, 12:17
RE: Playlist OrangeTV Addon - od Client - 20.5.2019, 12:21
RE: Playlist OrangeTV Addon - od Client - 25.5.2019, 10:32
RE: Playlist OrangeTV Addon - od marhycz - 22.5.2019, 12:31
RE: Playlist OrangeTV Addon - od eta - 29.5.2019, 15:57
RE: Playlist OrangeTV Addon - od havel - 07.6.2019, 21:49
RE: Playlist OrangeTV Addon - od otava5 - 14.8.2019, 16:11
RE: Playlist OrangeTV Addon - od havran99 - 14.8.2019, 16:30
RE: Playlist OrangeTV Addon - od eta - 15.8.2019, 21:26
RE: Playlist OrangeTV Addon - od otava5 - 14.8.2019, 20:06
RE: Playlist OrangeTV Addon - od Client - 15.8.2019, 4:05
RE: Playlist OrangeTV Addon - od otava5 - 17.8.2019, 20:52
RE: Playlist OrangeTV Addon - od Client - 18.8.2019, 19:36
RE: Playlist OrangeTV Addon - od otava5 - 18.8.2019, 21:09
RE: Playlist OrangeTV Addon - od Client - 22.8.2019, 2:47
RE: Playlist OrangeTV Addon - od otava5 - 22.8.2019, 7:05
RE: Playlist OrangeTV Addon - od Client - 22.8.2019, 10:06
RE: Playlist OrangeTV Addon - od otava5 - 22.8.2019, 19:48
RE: Playlist OrangeTV Addon - od Client - 16.9.2019, 6:54
RE: Playlist OrangeTV Addon - od otava5 - 16.9.2019, 7:12
RE: Playlist OrangeTV Addon - od Client - 16.9.2019, 17:42
RE: Playlist OrangeTV Addon - od otava5 - 17.9.2019, 7:58
RE: Playlist OrangeTV Addon - od Client - 17.9.2019, 10:25
RE: Playlist OrangeTV Addon - od teko8711 - 17.9.2019, 19:52
RE: Playlist OrangeTV Addon - od Client - 18.9.2019, 10:35
RE: Playlist OrangeTV Addon - od otava5 - 18.9.2019, 21:12
RE: Playlist OrangeTV Addon - od markydyl - 11.5.2020, 16:10
RE: Playlist OrangeTV Addon - od shumi21 - 12.5.2020, 15:49
RE: Playlist OrangeTV Addon - od ju-ro - 18.5.2020, 0:58
RE: Playlist OrangeTV Addon - od shumi21 - 18.5.2020, 19:40
RE: Playlist OrangeTV Addon - od markydyl - 18.5.2020, 20:50
RE: Playlist OrangeTV Addon - od ju-ro - 19.5.2020, 20:13
RE: Playlist OrangeTV Addon - od markydyl - 19.5.2020, 22:02
RE: Playlist OrangeTV Addon - od johnyzh94 - 24.5.2020, 17:56
RE: Playlist OrangeTV Addon - od ju-ro - 24.5.2020, 18:45
RE: Playlist OrangeTV Addon - od pvdeejay - 13.8.2020, 21:30
RE: Playlist OrangeTV Addon - od ju-ro - 30.9.2020, 18:08
RE: Playlist OrangeTV Addon - od markydyl - 06.10.2020, 9:56
RE: Playlist OrangeTV Addon - od otava5 - 06.10.2020, 20:22
RE: Playlist OrangeTV Addon - od ju-ro - 07.10.2020, 20:45
RE: Playlist OrangeTV Addon - od shumi21 - 12.11.2020, 18:48
Playlist OrangeTV Addon - od shumi21 - 18.11.2020, 20:16
RE: Playlist OrangeTV Addon - od havel - 18.12.2020, 5:16
RE: Playlist OrangeTV Addon - od 005jon - 27.12.2020, 18:22
RE: Playlist OrangeTV Addon - od djlucas - 29.12.2020, 23:31
RE: Playlist OrangeTV Addon - od 005jon - 30.12.2020, 13:04
RE: Playlist OrangeTV Addon - od shumi21 - 03.1.2021, 16:29
RE: Playlist OrangeTV Addon - od otava5 - 30.12.2020, 21:32
RE: Playlist OrangeTV Addon - od djlucas - 31.12.2020, 18:11
RE: Playlist OrangeTV Addon - od 005jon - 31.12.2020, 21:33
RE: Playlist OrangeTV Addon - od djlucas - 31.12.2020, 22:56
RE: Playlist OrangeTV Addon - od JiRo - 31.12.2020, 23:51
RE: Playlist OrangeTV Addon - od djlucas - 01.1.2021, 0:00
RE: Playlist OrangeTV Addon - od kolenac - 01.1.2021, 12:12
RE: Playlist OrangeTV Addon - od JiRo - 03.1.2021, 16:41
RE: Playlist OrangeTV Addon - od shumi21 - 04.1.2021, 12:40
RE: Playlist OrangeTV Addon - od typas - 08.1.2021, 14:34
RE: Playlist OrangeTV Addon - od ju-ro - 18.1.2021, 13:21
RE: Playlist OrangeTV Addon - od shumi21 - 30.1.2021, 18:19
RE: Playlist OrangeTV Addon - od shumi21 - 13.2.2021, 22:05
RE: Playlist OrangeTV Addon - od havel - 07.6.2021, 2:19
RE: Playlist OrangeTV Addon - od shumi21 - 08.6.2021, 19:15
RE: Playlist OrangeTV Addon - od havel - 10.6.2021, 19:17
RE: Playlist OrangeTV Addon - od shumi21 - 10.6.2021, 21:40
RE: Playlist OrangeTV Addon - od shumi21 - 14.10.2021, 20:21
RE: Playlist OrangeTV Addon - od shumi21 - 16.11.2021, 7:31

Přejít na fórum:


Prochází: 2 host(ů)