Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin.video.powerunlimited] 1.0.8+matrix.1 #4580

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.video.powerunlimited/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
xbmc.log("[ADDON] %s, Python Version %s" % (ADDON, str(sys.version)), xbmc.LOGDEBUG)
xbmc.log("[ADDON] %s v%s (%s) is starting, ARGV = %s" % (ADDON, VERSION, DATE, repr(sys.argv)),
xbmc.LOGDEBUG)
from resources.lib import powerunlimited_main as plugin
from resources.lib import powerunlimited_list as plugin
else:
action = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['action'][0]
#
Expand Down
15 changes: 9 additions & 6 deletions plugin.video.powerunlimited/addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<addon
id="plugin.video.powerunlimited"
name="PowerUnlimited Tv"
version="1.0.7+matrix.1"
version="1.0.8+matrix.1"
provider-name="Skipmode A1">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
Expand All @@ -18,17 +18,20 @@
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<summary lang="en_GB">Watch videos from PowerUnlimited Tv (dutch)</summary>
<description lang="en_GB">Watch videos from PowerUnlimited Tv (dutch)</description>
<disclaimer lang="en_GB">For bugs, requests or general questions visit the PowerUnlimited Tv thread on the Kodi forum.</disclaimer>
<description lang="en_GB">Watch videos from PowerUnlimited Tv (dutch)</description>
<disclaimer lang="en_GB">For bugs, requests or general questions visit the PowerUnlimited Tv thread on the Kodi forum.</disclaimer>
<summary lang="nl_NL">Bekijk videos van PowerUnlimited Tv (dutch)</summary>
<description lang="nl_NL">Bekijk videos van PowerUnlimited Tv (dutch)</description>
<disclaimer lang="nl_NL">Bugs of andere feedback op deze plugin kan geplaatst worden in de PowerUnlimited Tv thread op het Kodi forum.</disclaimer>
<description lang="nl_NL">Bekijk videos van PowerUnlimited Tv (dutch)</description>
<disclaimer lang="nl_NL">Bugs of andere feedback op deze plugin kan geplaatst worden in de PowerUnlimited Tv thread op het Kodi forum.</disclaimer>
<language>nl</language>
<platform>all</platform>
<license>GPL-2.0-or-later</license>
<forum>http://forum.xbmc.org/showthread.php?tid=203211</forum>
<website>http://www.pu.nl/</website>
<website>https://www.pu.nl/</website>
<source>https://github.com/skipmodea1/plugin.video.powerunlimited.python3</source>
<news>v1.0.8 (2024-10-04)
- updated the addon to use the changed website
</news>
<assets>
<icon>resources/icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
Expand Down
3 changes: 3 additions & 0 deletions plugin.video.powerunlimited/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v1.0.8 (2024-10-04)
- updated the addon to use the changed website

v1.0.7 (2018-01-20)
- removed looking for video dialogue
- addon now works in kode python 2 and should also work in python 3 (!!) once all dependencies work in python 3.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ msgid "For bugs, requests or general questions visit the PowerUnlimited Tv threa
msgstr ""

msgctxt "#30000"
msgid "All Videos"
msgid "Videos"
msgstr ""

msgctxt "#30001"
msgid "PU-TV"
msgid "Podcasts"
msgstr ""

msgctxt "#30002"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ msgid "For bugs, requests or general questions visit the PowerUnlimited Tv threa
msgstr "Bugs of andere feedback op deze plugin kan geplaatst worden in de PowerUnlimited Tv thread op het Kodi forum."

msgctxt "#30000"
msgid "All Videos"
msgstr "Alles"
msgid "Videos"
msgstr "Videos"

msgctxt "#30001"
msgid "PU-TV"
msgstr "PU-TV"
msgid "Podcasts"
msgstr "Podcasts"

msgctxt "#30002"
msgid "Trailers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
LANGUAGE = SETTINGS.getLocalizedString
IMAGES_PATH = os.path.join(xbmcaddon.Addon().getAddonInfo('path'), 'resources')
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'}
DATE = "2018-01-20"
VERSION = "1.0.7"
VIDEO_LIST_PAGE_URL = "https://pu.nl/artikelen/videos/"
DATE = "2024-10-04"
VERSION = "1.0.8"


if sys.version_info[0] > 2:
Expand Down
Binary file not shown.
195 changes: 37 additions & 158 deletions plugin.video.powerunlimited/resources/lib/powerunlimited_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
#
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import object
from resources.lib.powerunlimited_const import ADDON, LANGUAGE, IMAGES_PATH, HEADERS, convertToUnicodeString, log, getSoup
import os
import re
import sys
import urllib.request, urllib.parse, urllib.error
import xbmcgui
import xbmcplugin
import requests
import json

from resources.lib.powerunlimited_const import ADDON, IMAGES_PATH, HEADERS, VIDEO_LIST_PAGE_URL, convertToUnicodeString, log


#
Expand All @@ -34,33 +34,6 @@ def __init__(self):

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

# Parse parameters...
self.plugin_category = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['plugin_category'][0]
self.video_list_page_url = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['url'][0]
self.next_page_possible = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['next_page_possible'][0]

log("self.video_list_page_url", self.video_list_page_url)

if self.next_page_possible == 'True':
# Determine current item number, next item number, next_url
# http://www.pu.nl/media/pu-tv/?page=001/
pos_of_page = self.video_list_page_url.rfind('?page=')
if pos_of_page >= 0:
page_number_str = str(
self.video_list_page_url[pos_of_page + len('?page='):pos_of_page + len('?page=') + len('000')])
page_number = int(page_number_str)
self.current_page = page_number
page_number_next = page_number + 1
if page_number_next >= 100:
page_number_next_str = str(page_number_next)
elif page_number_next >= 10:
page_number_next_str = '0' + str(page_number_next)
else:
page_number_next_str = '00' + str(page_number_next)
self.next_url = str(self.video_list_page_url).replace(page_number_str, page_number_next_str)

log("self.next_url", self.next_url)

#
# Get the videos...
#
Expand All @@ -73,126 +46,47 @@ def getVideos(self):
#
# Init
#
# thumbnail_urls_index = 0
list_item = ''
# Create a list for our items.
# Create a list for our items
listing = []

#
# Get HTML page
#
response = requests.get(self.video_list_page_url, headers=HEADERS)
response = requests.get(VIDEO_LIST_PAGE_URL, headers=HEADERS)

html_source = response.text
html_source = convertToUnicodeString(html_source)

# Parse response
soup = getSoup(html_source)

# Get video-page-urls
# <a class='article pu-tv featured' href='/media/video/pu-tv/parodie-replacer/'>
# and not <a class='article' href='/games/briquid/'>
video_page_url_items = soup.findAll('a', attrs={'class': re.compile("^article")})

log("len(video_page_url_items", len(video_page_url_items))

for video_page_url_item in video_page_url_items:

log("video_page_url_item", video_page_url_item)

#<a class="article trailer featured" href="/media/video/trailer/pizza-connection-terug-trailer/"><span class="type"></span>
# <article><div class="article-image">
# <img alt="" src="http://cdn.pu.nl/thumbnails/144x123/e8a2a/pizza_maken.jpg" title=""/>
# </div><header><h4><strong>Pizzaatjes bakken</strong> in Pizza Connection -<strong> trailer</strong></h4></header><div class="date hidden-phone">

href = video_page_url_item['href']

# skip empty video link
if str(href) == '':

log("skipped empty href", href)

continue

# skip video link if starts with '/games/'
if str(href).startswith("/games/"):

log("skipped href with /games/", href)

continue

# skip video link if starts with '/media/gallery/'
if str(href).startswith("/media/gallery/"):

log("skipped href with /media/gallery/", href)

continue

# skip video link if starts with '/artikelen/'
if str(href).startswith("/artikelen/"):

log("skipped href with /artikelen/", href)

continue

video_page_url = "http://www.pu.nl/media/video%s" % href

log("video_page_url", video_page_url)

# Make title
# /media/video/pu-tv/parodie-replacer/
# /media/video/trailer/old-republic-dlc-video-laat-nieuwe-planeet-zien/
# remove the trailing /
title = str(href)
title = title[0:len(title) - len('/')]
pos_of_last_slash = title.rfind('/')
title = title[pos_of_last_slash + 1:]
title = title.capitalize()
title = title.replace('-', ' ')
title = title.replace('/', ' ')
title = title.replace(' i ', ' I ')
title = title.replace(' ii ', ' II ')
title = title.replace(' iii ', ' III ')
title = title.replace(' iv ', ' IV ')
title = title.replace(' v ', ' V ')
title = title.replace(' vi ', ' VI ')
title = title.replace(' vii ', ' VII ')
title = title.replace(' viii ', ' VIII ')
title = title.replace(' ix ', ' IX ')
title = title.replace(' x ', ' X ')
title = title.replace(' xi ', ' XI ')
title = title.replace(' xii ', ' XII ')
title = title.replace(' xiii ', ' XIII ')
title = title.replace(' xiv ', ' XIV ')
title = title.replace(' xv ', ' XV ')
title = title.replace(' xvi ', ' XVI ')
title = title.replace(' xvii ', ' XVII ')
title = title.replace(' xviii ', ' XVIII ')
title = title.replace(' xix ', ' XIX ')
title = title.replace(' xx ', ' XXX ')
title = title.replace(' xxi ', ' XXI ')
title = title.replace(' xxii ', ' XXII ')
title = title.replace(' xxiii ', ' XXIII ')
title = title.replace(' xxiv ', ' XXIV ')
title = title.replace(' xxv ', ' XXV ')
title = title.replace(' xxvi ', ' XXVI ')
title = title.replace(' xxvii ', ' XXVII ')
title = title.replace(' xxviii ', ' XXVIII ')
title = title.replace(' xxix ', ' XXIX ')
title = title.replace(' xxx ', ' XXX ')

log("title", title)

# find thumbnail url
start_pos_src_thumbnail_url = str(video_page_url_item).find('src="')
if start_pos_src_thumbnail_url >= 0:
start_pos_thumbnail_url = start_pos_src_thumbnail_url + len('src="')
end_pos_thumbnail_url = str(video_page_url_item).find('"', start_pos_thumbnail_url)
thumbnail_url = str(video_page_url_item)[start_pos_thumbnail_url:end_pos_thumbnail_url]
else:
thumbnail_url = ''

log("thumbnail_url", thumbnail_url)
# let's try and select the json containing all the needed data from the web page source
index_start = html_source.find('{"props"')
# log("index", index_start)
index_end = html_source.rfind('}')
# log("index", index_end)
json_data = html_source[index_start:index_end + 1]
# log("json_data", json_data)

# load the json into the json parser
data = json.loads(json_data)

# Access the "mp4Url" properties for each video
mp4_urls = [video['video']['video']['mp4Url'] for video in data['props']['pageProps']['_resources']['videos']]
# log("mp4_urls", mp4_urls)

# Access the "thumbnailUrl" properties for each video
thumbnail_urls = [video['video']['video']['thumbnailUrl'] for video in data['props']['pageProps']['_resources']['videos']]
# log("thumbnail_urls", thumbnail_urls)

# Access the "title" properties for each video
titles = [video['title'] for video in data['props']['pageProps']['_resources']['videos']]
# log("titles", titles)

mp4_urls_index = 0
for mp4_url in mp4_urls:

log("mp4_url", mp4_url)
title = titles[mp4_urls_index]
thumbnail_url = thumbnail_urls[mp4_urls_index]
video_page_url = mp4_urls[mp4_urls_index]

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

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

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