Skip to content

Commit 794c511

Browse files
committed
[plugin.video.powerunlimited] 1.0.8+matrix.1
1 parent be595dd commit 794c511

File tree

13 files changed

+65
-318
lines changed

13 files changed

+65
-318
lines changed

plugin.video.powerunlimited/addon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
xbmc.log("[ADDON] %s, Python Version %s" % (ADDON, str(sys.version)), xbmc.LOGDEBUG)
2222
xbmc.log("[ADDON] %s v%s (%s) is starting, ARGV = %s" % (ADDON, VERSION, DATE, repr(sys.argv)),
2323
xbmc.LOGDEBUG)
24-
from resources.lib import powerunlimited_main as plugin
24+
from resources.lib import powerunlimited_list as plugin
2525
else:
2626
action = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['action'][0]
2727
#

plugin.video.powerunlimited/addon.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<addon
33
id="plugin.video.powerunlimited"
44
name="PowerUnlimited Tv"
5-
version="1.0.7+matrix.1"
5+
version="1.0.8+matrix.1"
66
provider-name="Skipmode A1">
77
<requires>
88
<import addon="xbmc.python" version="3.0.0"/>
@@ -18,17 +18,20 @@
1818
<extension point="xbmc.addon.metadata">
1919
<platform>all</platform>
2020
<summary lang="en_GB">Watch videos from PowerUnlimited Tv (dutch)</summary>
21-
<description lang="en_GB">Watch videos from PowerUnlimited Tv (dutch)</description>
22-
<disclaimer lang="en_GB">For bugs, requests or general questions visit the PowerUnlimited Tv thread on the Kodi forum.</disclaimer>
21+
<description lang="en_GB">Watch videos from PowerUnlimited Tv (dutch)</description>
22+
<disclaimer lang="en_GB">For bugs, requests or general questions visit the PowerUnlimited Tv thread on the Kodi forum.</disclaimer>
2323
<summary lang="nl_NL">Bekijk videos van PowerUnlimited Tv (dutch)</summary>
24-
<description lang="nl_NL">Bekijk videos van PowerUnlimited Tv (dutch)</description>
25-
<disclaimer lang="nl_NL">Bugs of andere feedback op deze plugin kan geplaatst worden in de PowerUnlimited Tv thread op het Kodi forum.</disclaimer>
24+
<description lang="nl_NL">Bekijk videos van PowerUnlimited Tv (dutch)</description>
25+
<disclaimer lang="nl_NL">Bugs of andere feedback op deze plugin kan geplaatst worden in de PowerUnlimited Tv thread op het Kodi forum.</disclaimer>
2626
<language>nl</language>
2727
<platform>all</platform>
2828
<license>GPL-2.0-or-later</license>
2929
<forum>http://forum.xbmc.org/showthread.php?tid=203211</forum>
30-
<website>http://www.pu.nl/</website>
30+
<website>https://www.pu.nl/</website>
3131
<source>https://github.com/skipmodea1/plugin.video.powerunlimited.python3</source>
32+
<news>v1.0.8 (2024-10-04)
33+
- updated the addon to use the changed website
34+
</news>
3235
<assets>
3336
<icon>resources/icon.png</icon>
3437
<fanart>resources/fanart.jpg</fanart>

plugin.video.powerunlimited/changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v1.0.8 (2024-10-04)
2+
- updated the addon to use the changed website
3+
14
v1.0.7 (2018-01-20)
25
- removed looking for video dialogue
36
- addon now works in kode python 2 and should also work in python 3 (!!) once all dependencies work in python 3.

plugin.video.powerunlimited/resources/language/resource.language.en_gb/strings.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ msgid "For bugs, requests or general questions visit the PowerUnlimited Tv threa
2828
msgstr ""
2929

3030
msgctxt "#30000"
31-
msgid "All Videos"
31+
msgid "Videos"
3232
msgstr ""
3333

3434
msgctxt "#30001"
35-
msgid "PU-TV"
35+
msgid "Podcasts"
3636
msgstr ""
3737

3838
msgctxt "#30002"

plugin.video.powerunlimited/resources/language/resource.language.nl_nl/strings.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ msgid "For bugs, requests or general questions visit the PowerUnlimited Tv threa
2828
msgstr "Bugs of andere feedback op deze plugin kan geplaatst worden in de PowerUnlimited Tv thread op het Kodi forum."
2929

3030
msgctxt "#30000"
31-
msgid "All Videos"
32-
msgstr "Alles"
31+
msgid "Videos"
32+
msgstr "Videos"
3333

3434
msgctxt "#30001"
35-
msgid "PU-TV"
36-
msgstr "PU-TV"
35+
msgid "Podcasts"
36+
msgstr "Podcasts"
3737

3838
msgctxt "#30002"
3939
msgid "Trailers"

plugin.video.powerunlimited/resources/lib/powerunlimited_const.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
LANGUAGE = SETTINGS.getLocalizedString
1616
IMAGES_PATH = os.path.join(xbmcaddon.Addon().getAddonInfo('path'), 'resources')
1717
HEADERS = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
18-
DATE = "2018-01-20"
19-
VERSION = "1.0.7"
18+
VIDEO_LIST_PAGE_URL = "https://pu.nl/artikelen/videos/"
19+
DATE = "2024-10-04"
20+
VERSION = "1.0.8"
2021

2122

2223
if sys.version_info[0] > 2:
Binary file not shown.

plugin.video.powerunlimited/resources/lib/powerunlimited_list.py

Lines changed: 37 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
#
77
from future import standard_library
88
standard_library.install_aliases()
9-
from builtins import str
109
from builtins import object
11-
from resources.lib.powerunlimited_const import ADDON, LANGUAGE, IMAGES_PATH, HEADERS, convertToUnicodeString, log, getSoup
1210
import os
13-
import re
1411
import sys
1512
import urllib.request, urllib.parse, urllib.error
1613
import xbmcgui
1714
import xbmcplugin
1815
import requests
16+
import json
17+
18+
from resources.lib.powerunlimited_const import ADDON, IMAGES_PATH, HEADERS, VIDEO_LIST_PAGE_URL, convertToUnicodeString, log
1919

2020

2121
#
@@ -34,33 +34,6 @@ def __init__(self):
3434

3535
log("ARGV", repr(sys.argv))
3636

37-
# Parse parameters...
38-
self.plugin_category = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['plugin_category'][0]
39-
self.video_list_page_url = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['url'][0]
40-
self.next_page_possible = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['next_page_possible'][0]
41-
42-
log("self.video_list_page_url", self.video_list_page_url)
43-
44-
if self.next_page_possible == 'True':
45-
# Determine current item number, next item number, next_url
46-
# http://www.pu.nl/media/pu-tv/?page=001/
47-
pos_of_page = self.video_list_page_url.rfind('?page=')
48-
if pos_of_page >= 0:
49-
page_number_str = str(
50-
self.video_list_page_url[pos_of_page + len('?page='):pos_of_page + len('?page=') + len('000')])
51-
page_number = int(page_number_str)
52-
self.current_page = page_number
53-
page_number_next = page_number + 1
54-
if page_number_next >= 100:
55-
page_number_next_str = str(page_number_next)
56-
elif page_number_next >= 10:
57-
page_number_next_str = '0' + str(page_number_next)
58-
else:
59-
page_number_next_str = '00' + str(page_number_next)
60-
self.next_url = str(self.video_list_page_url).replace(page_number_str, page_number_next_str)
61-
62-
log("self.next_url", self.next_url)
63-
6437
#
6538
# Get the videos...
6639
#
@@ -73,126 +46,47 @@ def getVideos(self):
7346
#
7447
# Init
7548
#
76-
# thumbnail_urls_index = 0
77-
list_item = ''
78-
# Create a list for our items.
49+
# Create a list for our items
7950
listing = []
8051

8152
#
8253
# Get HTML page
8354
#
84-
response = requests.get(self.video_list_page_url, headers=HEADERS)
55+
response = requests.get(VIDEO_LIST_PAGE_URL, headers=HEADERS)
8556

8657
html_source = response.text
8758
html_source = convertToUnicodeString(html_source)
8859

89-
# Parse response
90-
soup = getSoup(html_source)
91-
92-
# Get video-page-urls
93-
# <a class='article pu-tv featured' href='/media/video/pu-tv/parodie-replacer/'>
94-
# and not <a class='article' href='/games/briquid/'>
95-
video_page_url_items = soup.findAll('a', attrs={'class': re.compile("^article")})
96-
97-
log("len(video_page_url_items", len(video_page_url_items))
98-
99-
for video_page_url_item in video_page_url_items:
100-
101-
log("video_page_url_item", video_page_url_item)
102-
103-
#<a class="article trailer featured" href="/media/video/trailer/pizza-connection-terug-trailer/"><span class="type"></span>
104-
# <article><div class="article-image">
105-
# <img alt="" src="http://cdn.pu.nl/thumbnails/144x123/e8a2a/pizza_maken.jpg" title=""/>
106-
# </div><header><h4><strong>Pizzaatjes bakken</strong> in Pizza Connection -<strong> trailer</strong></h4></header><div class="date hidden-phone">
107-
108-
href = video_page_url_item['href']
109-
110-
# skip empty video link
111-
if str(href) == '':
112-
113-
log("skipped empty href", href)
114-
115-
continue
116-
117-
# skip video link if starts with '/games/'
118-
if str(href).startswith("/games/"):
119-
120-
log("skipped href with /games/", href)
121-
122-
continue
123-
124-
# skip video link if starts with '/media/gallery/'
125-
if str(href).startswith("/media/gallery/"):
126-
127-
log("skipped href with /media/gallery/", href)
128-
129-
continue
130-
131-
# skip video link if starts with '/artikelen/'
132-
if str(href).startswith("/artikelen/"):
133-
134-
log("skipped href with /artikelen/", href)
135-
136-
continue
137-
138-
video_page_url = "http://www.pu.nl/media/video%s" % href
139-
140-
log("video_page_url", video_page_url)
141-
142-
# Make title
143-
# /media/video/pu-tv/parodie-replacer/
144-
# /media/video/trailer/old-republic-dlc-video-laat-nieuwe-planeet-zien/
145-
# remove the trailing /
146-
title = str(href)
147-
title = title[0:len(title) - len('/')]
148-
pos_of_last_slash = title.rfind('/')
149-
title = title[pos_of_last_slash + 1:]
150-
title = title.capitalize()
151-
title = title.replace('-', ' ')
152-
title = title.replace('/', ' ')
153-
title = title.replace(' i ', ' I ')
154-
title = title.replace(' ii ', ' II ')
155-
title = title.replace(' iii ', ' III ')
156-
title = title.replace(' iv ', ' IV ')
157-
title = title.replace(' v ', ' V ')
158-
title = title.replace(' vi ', ' VI ')
159-
title = title.replace(' vii ', ' VII ')
160-
title = title.replace(' viii ', ' VIII ')
161-
title = title.replace(' ix ', ' IX ')
162-
title = title.replace(' x ', ' X ')
163-
title = title.replace(' xi ', ' XI ')
164-
title = title.replace(' xii ', ' XII ')
165-
title = title.replace(' xiii ', ' XIII ')
166-
title = title.replace(' xiv ', ' XIV ')
167-
title = title.replace(' xv ', ' XV ')
168-
title = title.replace(' xvi ', ' XVI ')
169-
title = title.replace(' xvii ', ' XVII ')
170-
title = title.replace(' xviii ', ' XVIII ')
171-
title = title.replace(' xix ', ' XIX ')
172-
title = title.replace(' xx ', ' XXX ')
173-
title = title.replace(' xxi ', ' XXI ')
174-
title = title.replace(' xxii ', ' XXII ')
175-
title = title.replace(' xxiii ', ' XXIII ')
176-
title = title.replace(' xxiv ', ' XXIV ')
177-
title = title.replace(' xxv ', ' XXV ')
178-
title = title.replace(' xxvi ', ' XXVI ')
179-
title = title.replace(' xxvii ', ' XXVII ')
180-
title = title.replace(' xxviii ', ' XXVIII ')
181-
title = title.replace(' xxix ', ' XXIX ')
182-
title = title.replace(' xxx ', ' XXX ')
183-
184-
log("title", title)
185-
186-
# find thumbnail url
187-
start_pos_src_thumbnail_url = str(video_page_url_item).find('src="')
188-
if start_pos_src_thumbnail_url >= 0:
189-
start_pos_thumbnail_url = start_pos_src_thumbnail_url + len('src="')
190-
end_pos_thumbnail_url = str(video_page_url_item).find('"', start_pos_thumbnail_url)
191-
thumbnail_url = str(video_page_url_item)[start_pos_thumbnail_url:end_pos_thumbnail_url]
192-
else:
193-
thumbnail_url = ''
194-
195-
log("thumbnail_url", thumbnail_url)
60+
# let's try and select the json containing all the needed data from the web page source
61+
index_start = html_source.find('{"props"')
62+
# log("index", index_start)
63+
index_end = html_source.rfind('}')
64+
# log("index", index_end)
65+
json_data = html_source[index_start:index_end + 1]
66+
# log("json_data", json_data)
67+
68+
# load the json into the json parser
69+
data = json.loads(json_data)
70+
71+
# Access the "mp4Url" properties for each video
72+
mp4_urls = [video['video']['video']['mp4Url'] for video in data['props']['pageProps']['_resources']['videos']]
73+
# log("mp4_urls", mp4_urls)
74+
75+
# Access the "thumbnailUrl" properties for each video
76+
thumbnail_urls = [video['video']['video']['thumbnailUrl'] for video in data['props']['pageProps']['_resources']['videos']]
77+
# log("thumbnail_urls", thumbnail_urls)
78+
79+
# Access the "title" properties for each video
80+
titles = [video['title'] for video in data['props']['pageProps']['_resources']['videos']]
81+
# log("titles", titles)
82+
83+
mp4_urls_index = 0
84+
for mp4_url in mp4_urls:
85+
86+
log("mp4_url", mp4_url)
87+
title = titles[mp4_urls_index]
88+
thumbnail_url = thumbnail_urls[mp4_urls_index]
89+
video_page_url = mp4_urls[mp4_urls_index]
19690

19791
# Add to list
19892
list_item = xbmcgui.ListItem(label=title)
@@ -208,22 +102,7 @@ def getVideos(self):
208102
# Add our item to the listing as a 3-element tuple.
209103
listing.append((url, list_item, is_folder))
210104

211-
# Next page entry
212-
if self.next_page_possible == 'True':
213-
next_page = self.current_page + 1
214-
thumbnail_url = os.path.join(IMAGES_PATH, 'next-page.png')
215-
list_item = xbmcgui.ListItem(LANGUAGE(30503))
216-
list_item.setArt({'thumb': thumbnail_url, 'icon': thumbnail_url,
217-
'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')})
218-
list_item.setProperty('IsPlayable', 'false')
219-
parameters = {"action": "list", "plugin_category": self.plugin_category, "url": str(self.next_url),
220-
"next_page_possible": self.next_page_possible}
221-
url = self.plugin_url + '?' + urllib.parse.urlencode(parameters)
222-
is_folder = True
223-
# Add refresh option to context menu
224-
list_item.addContextMenuItems([('Refresh', 'Container.Refresh')])
225-
# Add our item to the listing as a 3-element tuple.
226-
listing.append((url, list_item, is_folder))
105+
mp4_urls_index = mp4_urls_index + 1
227106

228107
# Add our listing to Kodi
229108
# Large lists and/or slower systems benefit from adding all items at once via addDirectoryItems
@@ -232,4 +111,4 @@ def getVideos(self):
232111
# Disable sorting
233112
xbmcplugin.addSortMethod(handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE)
234113
# Finish creating a virtual folder.
235-
xbmcplugin.endOfDirectory(self.plugin_handle)
114+
xbmcplugin.endOfDirectory(self.plugin_handle)
Binary file not shown.

0 commit comments

Comments
 (0)