Skip to content

Commit

Permalink
Fix playback and speedup requests
Browse files Browse the repository at this point in the history
  • Loading branch information
enen92 committed Dec 3, 2019
1 parent 9833792 commit d4586c9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
6 changes: 2 additions & 4 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.rtpplay" name="RTP Play" version="5.0.1" provider-name="enen92, guipenedo">
<addon id="plugin.video.rtpplay" name="RTP Play" version="5.0.2" provider-name="enen92, guipenedo">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.routing" version="0.2.0"/>
Expand All @@ -21,9 +21,7 @@
<email>[email protected]</email>
<source>https://github.com/enen92/plugin.video.rtpplay</source>
<news>
- Added progress percentage to live tv
- Added programs from RTPPlay
- Added searching
- Fix on demand section
</news>
<disclaimer lang="en_GB">The plugin is unnoficial and not endorsed by RTP. Expect it to break. </disclaimer>
<assets>
Expand Down
40 changes: 24 additions & 16 deletions resources/lib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def index():
def search():

input_text = Dialog().input(kodiutils.get_string(32007), "", INPUT_ALPHANUM)

try:
req = requests.get("https://www.rtp.pt/play/pesquisa?q={}".format(input_text), headers=HEADERS).text
except:
Expand All @@ -65,7 +65,7 @@ def search():
img = a.find('img').get('src')
metas = a.find_next_sibling('i').find_all('meta')
description = metas[1].get('content')

liz = ListItem("{}".format(kodiutils.compat_py23str(title)))
liz.setArt({"thumb": img,
"icon": img,
Expand Down Expand Up @@ -187,7 +187,9 @@ def live_play():
def programs():
# Request dvr
try:
req = requests.get("http://www.rtp.pt/play/programas", headers=HEADERS).text
req = requests.get("http://www.rtp.pt/play/programas", headers=HEADERS)
req.encoding = "latin-1"
req = req.text
except:
raise_notification()

Expand All @@ -213,7 +215,9 @@ def programs_category():
try:
req = requests.get("https://www.rtp.pt/play/bg_l_pg/?listcategory={}&page={}".format(
cat_id,
page), headers=HEADERS).text
page), headers=HEADERS)
req.encoding = "latin-1"
req = req.text
except:
raise_notification()

Expand All @@ -230,7 +234,7 @@ def programs_category():
metas = a.find_next_sibling('i').find_all('meta')
description = metas[1].get('content')
ep = metas[0].get('content')[-12:]

liz = ListItem("{} ({})".format(
kodiutils.compat_py23str(title),
kodiutils.compat_py23str(ep))
Expand Down Expand Up @@ -272,7 +276,9 @@ def programs_episodes():
try:
req = requests.get("https://www.rtp.pt/play/bg_l_ep/?listProgram={}&page={}".format(
prog_id,
page), headers=HEADERS).text
page), headers=HEADERS)
req.encoding = "latin-1"
req = req.text
except:
raise_notification()

Expand All @@ -291,7 +297,7 @@ def programs_episodes():
metas = a.find_next_sibling('i').find_all('meta')
description = metas[1].get('content')
ep = metas[0].get('content')

liz = ListItem(ep)
liz.setArt({"thumb": img,
"icon": img,
Expand All @@ -312,14 +318,14 @@ def programs_episodes():

newpage = str(int(page) + 1)
nextpage = ListItem("[B]{}[/B] - {} {} >>>".format(kodiutils.compat_py23str(title), kodiutils.get_string(32009), newpage))
addDirectoryItem(handle=plugin.handle,
listitem=nextpage,
isFolder=True,
url=plugin.url_for(programs_episodes,
title=kodiutils.compat_py23str(title),
addDirectoryItem(handle=plugin.handle,
listitem=nextpage,
isFolder=True,
url=plugin.url_for(programs_episodes,
title=kodiutils.compat_py23str(title),
ep=kodiutils.compat_py23str(ep),
img=kodiutils.compat_py23str(img),
url=kodiutils.compat_py23str(url),
img=kodiutils.compat_py23str(img),
url=kodiutils.compat_py23str(url),
page=newpage))

endOfDirectory(plugin.handle)
Expand All @@ -333,8 +339,10 @@ def programs_play():
url = plugin.args["url"][0]

try:
req = requests.get("https://www.rtp.pt" + url, headers=HEADERS).text
stream = "https://streaming-ondemand.rtp.pt" + re.search(r'"https://streaming-ondemand.rtp.pt(.*)"', req).group(1)
req = requests.get("https://www.rtp.pt" + url, headers=HEADERS)
req.encoding = "utf-8"
stream = re.search(r'"https://(.+?)ondemand.rtp.pt(.*)"', req.text)
stream = "https://" + stream.group(1) + "ondemand.rtp.pt" + stream.group(2)
except:
raise_notification()

Expand Down

0 comments on commit d4586c9

Please sign in to comment.