Skip to content

Commit a211311

Browse files
committed
[plugin.video.sandmann] v2.4.0
- make plugin work again (switch source)
1 parent 6b79c08 commit a211311

7 files changed

Lines changed: 81 additions & 154 deletions

File tree

plugin.video.sandmann/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ If you find a bug or have an idea for an new feature - please submit it to GitHu
1212

1313
## Contributors
1414

15-
- [sorax](https://github.com/sorax), [handfrog](https://github.com/handfrog)
16-
- Special thanks to [chefmagier](https://github.com/chefmagier), [yafp](https://github.com/yafp), [OBedford](https://github.com/OBedford), [kevleodev](https://github.com/kevleodev)
15+
- [sorax](https://github.com/sorax), [handfrog](https://github.com/handfrog), [benjwin](https://github.com/benjwin)
16+
17+
### Special thanks to everyone who is reporting issues!
18+
19+
- [chefmagier](https://github.com/chefmagier), [yafp](https://github.com/yafp), [OBedford](https://github.com/OBedford), [kevleodev](https://github.com/kevleodev), [IT-Ludwig](https://github.com/IT-Ludwig), [benjwin](https://github.com/benjwin), [tobybear](https://github.com/tobybear), [tribut](https://github.com/tribut)

plugin.video.sandmann/addon.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<addon id="plugin.video.sandmann" name="Sandmann" version="2.3.1" provider-name="sorax">
2+
<addon id="plugin.video.sandmann" name="Sandmann" version="2.4.0" provider-name="sorax">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0"></import>
55
<import addon="script.module.requests"/>
6+
<import addon="script.module.beautifulsoup4"/>
67
</requires>
78
<extension point="xbmc.python.pluginsource" library="main.py">
89
<provides>video</provides>
@@ -23,8 +24,8 @@
2324
<icon>resources/assets/icon.png</icon>
2425
<fanart>resources/assets/fanart.jpg</fanart>
2526
</assets>
26-
<news>v2.3.1:
27-
- fix urls for fetching episodes
27+
<news>v2.4.0:
28+
- use sandmann.de as the official source for videos and metadata
2829
</news>
2930
</extension>
3031
</addon>

plugin.video.sandmann/changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
version 2.4.0:
2+
* use sandmann.de as the official source for videos and metadata
3+
version 2.3.1:
4+
* fix urls for fetching episodes
15
version 2.3.0:
26
* performance improvements
37
version 2.2.2:

plugin.video.sandmann/libs/episode.py

Lines changed: 0 additions & 84 deletions
This file was deleted.

plugin.video.sandmann/libs/network.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
import requests
1919

2020

21-
def getJsonFromUrl(url):
21+
def fetchHtml(url):
22+
r = requests.get(url)
23+
r.encoding = "utf-8"
24+
return r.text
25+
26+
27+
def fetchJson(url):
2228
r = requests.get(url)
2329
return r.json()

plugin.video.sandmann/libs/sandmann.py

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
import xbmcgui
2020
import xbmcplugin
2121

22+
import json
2223
import sys
2324

24-
from libs.show import getEpisodes
25-
from libs.episode import mapEpisode, appendStreams
25+
from bs4 import BeautifulSoup
26+
27+
from libs.network import fetchHtml
28+
from libs.network import fetchJson
2629

2730

2831
# -- Addon --
@@ -34,13 +37,6 @@
3437
base_path = sys.argv[0]
3538

3639

37-
# -- Constants --
38-
sources = {
39-
"rbb": "https://api.ardmediathek.de/page-gateway/widgets/ard/editorials/3GuLb6bWPNyeenTBjK9u5l%3A7561660580516351848?pageNumber=0&pageSize=100",
40-
"mdr": "https://api.ardmediathek.de/page-gateway/widgets/ard/editorials/3GuLb6bWPNyeenTBjK9u5l%3A7561660580516351848?pageNumber=0&pageSize=100"
41-
}
42-
43-
4440
# -- Settings --
4541
dgs = addon.getSettingInt("dgs2")
4642
interval = addon.getSettingInt("interval2")
@@ -50,48 +46,75 @@
5046

5147

5248
def sandmann():
53-
if update == 1:
54-
li_refresh = xbmcgui.ListItem(label=addon.getLocalizedString(30020))
55-
xbmcplugin.addDirectoryItem(addon_handle, base_path, li_refresh, True)
49+
li_refresh = xbmcgui.ListItem(label=addon.getLocalizedString(30020))
50+
xbmcplugin.addDirectoryItem(addon_handle, base_path, li_refresh, True)
5651

57-
url = sources["rbb"]
58-
if source == 1:
59-
url = sources["mdr"]
52+
html = fetchWebsite()
6053

61-
episodes = getEpisodes(url)
62-
episodes2 = map(mapEpisode, episodes)
63-
episodes3 = filterDgs(episodes2, dgs)
64-
episodes4 = map(appendStreams, episodes3)
54+
if dgs == 0:
55+
episodes = getEpisodes(html, 1)
56+
elif dgs == 2:
57+
episodes = getEpisodes(html, 2)
58+
else:
59+
episodes = getEpisodes(html, 1) + getEpisodes(html, 2)
6560

6661
item_list = []
67-
for episode in episodes4:
68-
item_list.append((getStream(episode, quality), getListItem(episode), False))
62+
for episode, description in episodes:
63+
path = getEpisodePath(episode)
64+
details = fetchEpisodeDetails(path)
6965

70-
xbmcplugin.addDirectoryItems(addon_handle, item_list, len(item_list))
66+
item_list.append((details["stream"], getListItem(details, description), False))
7167

68+
# xbmcgui.Dialog().ok("DEBUG", f'{item_list[0]}')
69+
xbmcplugin.addDirectoryItems(addon_handle, item_list, len(item_list))
7270
xbmcplugin.endOfDirectory(addon_handle)
7371

7472

75-
def filterDgs(episodes, dgs):
76-
if dgs == 0:
77-
return [e for e in episodes if e["dgs"] == False]
78-
elif dgs == 2:
79-
return [e for e in episodes if e["dgs"] == True]
80-
else:
81-
return episodes
73+
def fetchWebsite():
74+
url = "https://www.sandmann.de/videos/"
75+
html = fetchHtml(url)
8276

77+
return html
8378

84-
def getStream(episode, quality):
85-
streams = episode["streams"]
8679

87-
index = quality - 1
88-
if index in streams:
89-
return streams[index]
90-
else:
91-
return streams["auto"]
80+
def getEpisodes(html, count):
81+
soup = BeautifulSoup(html, "html.parser")
82+
episodes = soup.select(f"#main > .count{count} .manualteaserpicture")
83+
html_descriptions = soup.select(f"#main > .count{count} .manualteasershorttext p")
84+
descriptions = [p.get_text() for p in html_descriptions]
85+
86+
return list(zip(episodes, descriptions))
87+
88+
89+
def getEpisodePath(episode):
90+
jsb_string = episode.get("data-jsb")
91+
jsb_object = json.loads(jsb_string)
92+
93+
return jsb_object["media"]
94+
95+
96+
def fetchEpisodeDetails(path):
97+
json = fetchJson(f"https://www.sandmann.de{path}")
98+
99+
streams = {}
100+
for stream in json["_mediaArray"][0]["_mediaStreamArray"]:
101+
streams[stream["_quality"]] = stream["_stream"]
102+
103+
title = json["rbbtitle"].split(" | ")
104+
previewImage = "https://www.sandmann.de" + json["_previewImage"].rsplit("/", 1)[0]
105+
106+
return {
107+
"date": title[2],
108+
# "dgs": json["dgs"],
109+
"duration": json["_duration"],
110+
"fanart": previewImage + "/size=1920x1080.jpg",
111+
"stream": streams["auto"],
112+
"thumb": previewImage + "/size=640x360.jpg",
113+
"title": f"{title[2]} | {title[0]}"
114+
}
92115

93116

94-
def getListItem(item):
117+
def getListItem(item, description):
95118
li = xbmcgui.ListItem()
96119
li.setLabel(item["title"])
97120
li.setArt({
@@ -103,7 +126,7 @@ def getListItem(item):
103126
infoLabels={
104127
"aired": item["date"],
105128
"duration": item["duration"],
106-
"plot": item["desc"],
129+
"plot": description,
107130
}
108131
)
109132
li.setProperty("IsPlayable", "true")

plugin.video.sandmann/libs/show.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)