Skip to content

Commit

Permalink
direct Uri #108 (serviceapi only)
Browse files Browse the repository at this point in the history
  • Loading branch information
s0faking committed Dec 6, 2022
1 parent ee5a8d6 commit 73d72b9
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,30 @@ Known Issues
* you tell me


Simple IPTV Integration
-----------------

Playlist Content
```
#EXTINF:-1 tvg-name="ORF 1" tvg-id="ORF 1" group-title="ORF",orf1
plugin://plugin.video.orftvthek/?channel=orf1&mode=pvr
#EXTINF:-1 tvg-name="ORF 2" tvg-id="ORF 2" group-title="ORF",orf2
plugin://plugin.video.orftvthek/?channel=orf2&mode=pvr
#EXTINF:-1 tvg-name="ORF 3" tvg-id="ORF 3" group-title="ORF",orf3
plugin://plugin.video.orftvthek/?channel=orf3&mode=pvr
#EXTINF:-1 tvg-name="ORF Sport+" tvg-id="ORF Sport+" group-title="ORF",orfs
plugin://plugin.video.orftvthek/?channel=orfs&mode=pvr
```


Legal
-----
This addon provides access to videos on the ORF TVthek Website but is not endorsed, certified or otherwise approved in any way by ORF.

Icons
-----
https://uxwing.com
https://uxwing.com
31 changes: 31 additions & 0 deletions resources/lib/Addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,37 @@ def run():
listCallback(False, pluginhandle)
except:
userNotification((translation(30067)).encode("utf-8"))
elif mode == 'pvr':
channel = params.get('channel')
debugLog("Loading channel %s" % channel)
data = scraper.getLivestreamByChannel(channel)
video_url = "%s|User-Agent=%s" % (data['url'], Settings.userAgent())

if 'license' in data:
import inputstreamhelper
license = data['license']
print(data)
is_helper = inputstreamhelper.Helper(input_stream_protocol, drm=input_stream_drm_version)
if is_helper.check_inputstream():
debugLog("Video Url: %s" % video_url)
debugLog("DRM License Url: %s" % license)
play_item = xbmcgui.ListItem(path=video_url)
play_item.setProperty('IsPlayable', 'true')
headers = "User-Agent=%s&Content-Type=%s" % (Settings.userAgent(), input_stream_lic_content_type)

play_item.setContentLookup(False)
play_item.setMimeType(input_stream_mime)
play_item.setProperty('inputstream.adaptive.stream_headers', headers)
play_item.setProperty('inputstream', is_helper.inputstream_addon)
play_item.setProperty('inputstream.adaptive.manifest_type', input_stream_protocol)
play_item.setProperty('inputstream.adaptive.license_type', input_stream_drm_version)
play_item.setProperty('inputstream.adaptive.license_key', license + '|' + headers + '|R{SSM}|')
xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=play_item)
else:
userNotification((translation(30066)).encode("utf-8"))
else:
play_item = xbmcgui.ListItem(path=video_url)
xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=play_item)
elif sys.argv[2] == '':
getMainMenu()
else:
Expand Down
2 changes: 2 additions & 0 deletions resources/lib/HtmlScraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def __init__(self, xbmc, settings, pluginhandle, quality, protocol, delivery, de
self.usePlayAllPlaylist = usePlayAllPlaylist
debugLog('HTML Scraper - Init done')

def getLivestreamByChannel(self, channel):
return []

def getMostViewed(self):
self.getTeaserList(self.__urlMostViewed, "b-teasers-list")
Expand Down
4 changes: 4 additions & 0 deletions resources/lib/Scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ def getSchedule(self):
@abc.abstractmethod
def getArchiv(self):
pass

@abc.abstractmethod
def getLivestreamByChannel(self, channel):
pass
34 changes: 32 additions & 2 deletions resources/lib/ServiceApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class serviceAPI(Scraper):
__urlBase = 'https://api-tvthek.orf.at/api/v3/'
__urlBaseV4 = 'https://api-tvthek.orf.at/api/v4.2/'
__urlLive = 'livestreams/24hours?limit=20'
__urlLiveChannels = 'livestreams'
__urlMostViewed = 'page/startpage'
__urlNewest = 'page/startpage/newest'
__urlSearch = __urlBase + 'search/%s?limit=1000'
Expand Down Expand Up @@ -52,6 +53,33 @@ def __init__(self, xbmc, settings, pluginhandle, quality, protocol, delivery, de
self.usePlayAllPlaylist = usePlayAllPlaylist
debugLog('ServiceAPI - Init done', xbmc.LOGDEBUG)

def getLivestreamByChannel(self, channel):
response = self.__makeRequestV4(self.__urlLiveChannels)
response_raw = response.read().decode('UTF-8')
channels = json.loads(response_raw)

for result in channels:
if result == channel:
live_link = channels[result].get('items')[0].get('_links').get('self').get('href')
response = url_get_request(live_link, self.httpauth)
response_raw = response.read().decode('UTF-8')
live_json = json.loads(response_raw)
print("##################")
print(live_json)
print("##################")
if live_json.get('is_drm_protected'):
video_url = self.JSONStreamingDrmURL(live_json)
license_url = self.JSONLicenseDrmURL(live_json)
print(video_url)
print(license_url)
print("########################################")
return {'url': video_url,'license': license_url}
else:
video_url = self.JSONStreamingURL(live_json.get('sources'))
print(video_url)
print("########################################")
return {'url': video_url}

def getHighlights(self):
try:
response = self.__makeRequest(self.serviceAPIHighlights)
Expand Down Expand Up @@ -130,8 +158,10 @@ def JSONStreamingURL(self, jsonVideos):

for streamingUrl in jsonVideos.get('hls'):
if streamingUrl.get('quality_key') == self.videoQuality:
return generateAddonVideoUrl(streamingUrl.get('src'))
source = streamingUrl.get('src')
# Remove Get Parameters because InputStream Adaptive cant handle it.
source = re.sub(r"\?[\S]+", '', streamingUrl.get('src'), 0)
return generateAddonVideoUrl(source)
source = re.sub(r"\?[\S]+", '', streamingUrl.get('src'), 0)
if source is not None:
return generateAddonVideoUrl(source)
else:
Expand Down

0 comments on commit 73d72b9

Please sign in to comment.