Skip to content

Commit

Permalink
V0.9.2: Addon auf Mozilla Webpage, Korrektur von Tipfehlern und CSS.
Browse files Browse the repository at this point in the history
  • Loading branch information
KWich committed Jan 20, 2023
1 parent 683abc5 commit 0255368
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 56 deletions.
9 changes: 7 additions & 2 deletions docs/addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@

Über die Verwaltungsseite kann eine signiertes Firefox Add-on "MyMediathek" heruntergeladen werden, welches es ermöglicht Beiträge von den ARD, ZDF, 3SAT und ARTE Mediatheken direkt in die Merkliste zu übernehmen oder mit dem Standardplayer abzuspielen.

Hinweis:<br>
Das Addon steht auf der Mozilla Addon Seite [https://addons.mozilla.org/de/firefox/](https://addons.mozilla.org/de/firefox/addon/mymediathek) unter dem Namen '[MyMediathek](https://addons.mozilla.org/de/firefox/addon/mymediathek)' zur Verfügung.

<br>

## Installation in Firefox ##

- Nach dem Herunterladen im Firefox Add-on Menü die Option "Add-on aus Datei installieren" auswählen um das Add-on zu Firefox hinzufügen:
- Beim Laden des Addons mit Firefox kann dieses dirkt installiert werden. Ansonsten nach dem Herunterladen im Firefox Add-on Menü die Option "Add-on aus Datei installieren" auswählen um das Add-on zu Firefox hinzufügen:

<img src="images/Firefox1.png" alt="drawing" width="500"/>

Damit das Addon mit 'MyMediathek' zusammen arbeitet, muß in diesem noch die Adresse des Servers eingetragen werden. Dazu:

- Die Verwaltung des Add-ons aufrufen - Im Punktemenü auf Verwalten gehen:

<img src="images/Firefox2.png" alt="drawing" width="500"/>
Expand All @@ -23,7 +28,7 @@

Und mit "Speichern" sichern.

Anschliesend kann mit dem Button "Teste Serververbeindung" geprüft werden, ob der (richtige) Server erreicht wirden kann.
Anschliesend kann mit dem Button "Teste Serververbindung" geprüft werden, ob der (richtige) Server erreicht wirden kann.

<br>

Expand Down
5 changes: 2 additions & 3 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ module.exports = function (grunt) {
"**//*.css",
"**//*.svg",
"**//*.png",
"**//*.yaml",
"**//*.xpi",
"**//*.yaml"
],
expand: true
},
Expand Down Expand Up @@ -78,6 +77,7 @@ module.exports = function (grunt) {
"uninstall.sh",
"start.sh",
"my*.sh",
"update*.sh",
],
dest: 'scripts/',
expand: true
Expand All @@ -100,7 +100,6 @@ module.exports = function (grunt) {
"**//*.svg",
"**//*.png",
"**//*.yaml",
"**//*.xpi",
],
expand: true
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "myMediathek",
"version": "0.9.1",
"version": "0.9.2",
"scripts": {
"start": "run-script-os",
"start:default": "echo 'not supported platform'",
Expand Down
10 changes: 9 additions & 1 deletion scripts/mymediathek.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ update() {
sudo chmod a+w "$myInstallPath";
echo " * Installationsverzeichnis ${myInstallPath} wurde schreibbar gemacht"
fi
echo " * Server Dateien nach $myInstallPath kopieren ..."
echo -n " * Server Dateien nach $myInstallPath kopieren ..."
sudo cp -r "$installDir"/server/. "$myInstallPath"/server
sudo cp -r "$installDir"/scripts/. "$myInstallPath"/scripts
sudo chmod +x "$myInstallPath"/scripts/*.sh
Expand All @@ -39,6 +39,14 @@ update() {
sudo chmod a+x "$myInstallPath"/start.sh
echo " Fertig"

echo -n " * Zusätzliche Update Aufgaben durchführen: "
if [[ -f "${installDir}/scripts/updateadditionaltask.sh" ]]; then
source ${installDir}/scripts/updateadditionaltask.sh
else
echo " keine konfiguriert"
fi


echo -n " * Dateien dem Benutzer ${myUserName} zuweisen ..."
sudo chown -R "${myUser}":"${myUser}" "$myInstallPath"
echo " Fertig"
Expand Down
4 changes: 2 additions & 2 deletions scripts/start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ goto :init


:usage
echo Starte MyMediathek 0.9.1 (13/01/2023) - Optionen
echo Starte MyMediathek Vx.x - Optionen
echo.
echo %__BAT_NAME% [flags]
echo.
Expand Down Expand Up @@ -36,7 +36,7 @@ goto :init

:main

echo Starte MyMediathek 0.9.1 (13/01/2023)
echo Starte MyMediathek Vx.x
echo.

if defined OptVerbose (
Expand Down
20 changes: 20 additions & 0 deletions scripts/updateadditionaltask.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# (c) 2022-2023 Klaus Wich
#
# Additional update task(s)
#
# This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license

echo
echo " - Start cleanup:"
echo " - Installationsverzeichnis : $myInstallPath"
echo " - Benutzer : $myUser"

if [[ -d "${myInstallPath}/server/api/static/addon" ]]; then
echo " - Remove Addon directory"
sudo rm -r ${myInstallPath}/server/api/static/addon
fi

echo " Cleanup done"
7 changes: 2 additions & 5 deletions src/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def printInfo():
print ("\n Einstellungen:")
print (" * INI Datei : " + inifile)
print (" * Database Datei : " + dbname)
print (" * Bassisverzeichnis : " + str(basedir))
print (" * Basisverzeichnis : " + str(basedir))
print (" * Debugmodus : " + ("aktiv" if cfgConfig.getboolean("develop","enable_debug_mode", fallback=False) else "inaktiv"))
if cfgConfig.getboolean("develop","enable_swagger_ui", fallback=False):
print (" * Swagger UI : aktiv")
Expand Down Expand Up @@ -62,12 +62,9 @@ def printInfo():
log = logging.getLogger('werkzeug')
log.setLevel(loglevel)

# Build the Sqlite ULR for SqlAlchemy
sqlite_url = "sqlite:///" + dbname

# Configure the SqlAlchemy part of the app instance
app.config["SQLALCHEMY_ECHO"] = False
app.config["SQLALCHEMY_DATABASE_URI"] = sqlite_url
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + dbname
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

# Configure the Flask part of the app instance
Expand Down
2 changes: 1 addition & 1 deletion src/api/static/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ <h2 class="container title">Erweiterungen:</h2>
<article>
<form class="card">
<div>Firefox Browser Add-on</div>
<button type="submit" formaction="addon/Merkliste-0.5.xpi" class="listbtn cardright">herunterladen</button>
<button type="submit" formaction="https://addons.mozilla.org/de/firefox/addon/mymediathek/" class="listbtn cardright">herunterladen</button>
</form>
</article>
<div class="leer">&nbsp;</div>
Expand Down
2 changes: 1 addition & 1 deletion src/api/static/css/kw.css
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ h3.container {
}

#wait {
animation: 0.3s waitmove 3s infinite;
animation: waitmove 3s linear 0.3s infinite;
height: 100px;
left: 50%;
margin-left: -50px;
Expand Down
9 changes: 4 additions & 5 deletions src/api/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function getARDInfoMovieListSuccess(response) {
let ts = sender.getARDExpiryStringFromJSON(json);
let imgsrc = sender.getARDImageURLFromJSON(json);
let res = sender.getARDStreamQuality(json, currentQueryObj.getAttribute("data-url"));
updateMovieExpiryImageAndStream(ts, imgsrc, res.quality, (res.found ? null : res.stream));
updateMovieExpiryImageAndStream(ts, imgsrc, res.quality); // (res.found ? null : res.stream));
}
util.utilSetWait(false);
showExtended(currentQueryObj, movieList, header);
Expand All @@ -196,8 +196,8 @@ function getARTEInfoMovieListSuccess(response) {
if (json) {
let ts = sender.getARTEExpiryStringFromJSON(json);
let imgsrc = sender.getARTEImageURLFromJSON(json);
let res = sender.getARTEStreamQuality(json, currentQueryObj.getAttribute("data-url"));
updateMovieExpiryImageAndStream(ts, imgsrc, res.quality, (res.found ? null : res.stream));
let res = sender.getARTEStreamQuality(json.data.attributes.streams, currentQueryObj.getAttribute("data-url"));
updateMovieExpiryImageAndStream(ts, imgsrc, res.quality); // (res.found ? null : res.stream));
}
util.utilSetWait(false);
showExtended(currentQueryObj, movieList, header);
Expand All @@ -217,7 +217,7 @@ function getZDF3SATInfoMovieListSuccess(response) {
}


function updateMovieExpiryImageAndStream(ts, imgurl, quality = null, stream = null, details = null) {
function updateMovieExpiryImageAndStream(ts, imgurl, quality, stream, details) {
if (details) {
currentQueryObj.children[0].children[1].innerHTML = currentQueryObj.children[0].children[1].innerHTML + " (Folge: " + details + ")";
}
Expand Down Expand Up @@ -1159,7 +1159,6 @@ function playbookmarkurl(event) {
function playBookmarkResponse() {
util.utilViewPopUp("Film wurde gestartet");
util.utilSendHttpRequest("PATCH", gBookmarkServerUrl + "/api/bookmarks/" + bookList.currentCard.getAttribute("data-hash") + "/seen?seen=true", null, false, setCurrentSeen);
//setCurrentSeen();
}


Expand Down
105 changes: 72 additions & 33 deletions src/api/static/js/sender.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* MyMediathek: Sender specific export export functions
* Sender specific export functions
**/
"use strict";

Expand All @@ -11,7 +11,7 @@ import {cfgCORS_ProxyServer} from "../config/config.js";
* Checks if given url points to ARD and triggers retrieval of movie info
* @return {boolean} True if ARD movie URL, False if other or error occurred
*/
export function checkAndQueryARDMovieInfo(url, successFunc, errorFunc = null) {
export function checkAndQueryARDMovieInfo(url, successFunc, errorFunc) {
let rc = false;
if (url && url.indexOf("ardmediathek") > -1) {
// get ARD id
Expand All @@ -30,7 +30,7 @@ export function checkAndQueryARDMovieInfo(url, successFunc, errorFunc = null) {
* Checks if given url points to ARTE and triggers retrieval of movie info
* @return {boolean} True if ARTE movie URL, False if other or error in url occurred
*/
export function checkAndQueryARTEMovieInfo(url, successFunc, errorFunc = null) {
export function checkAndQueryARTEMovieInfo(url, successFunc, errorFunc) {
let rc = false;
if (url && url.indexOf("www.arte.tv") > -1) {
// get ARTE id
Expand All @@ -40,9 +40,11 @@ export function checkAndQueryARTEMovieInfo(url, successFunc, errorFunc = null) {
idx = surl.indexOf("/");
if (idx > -1) {
surl = surl.substring(0, idx);
let addheader = {name:"X-Requested-With", content:"BookmarkServer"};
utilSendHttpRequest("GET", cfgCORS_ProxyServer + "https://api.arte.tv/api/player/v2/config/de/" + surl + "?platform=ARTE_NEXT", null, false, successFunc, errorFunc, addheader) ;
rc = true;
if (surl.length > 5 && surl.indexOf("fernsehfilme") == -1) {
let addheader = {name:"X-Requested-With", content:"MyMediathek"};
utilSendHttpRequest("GET", cfgCORS_ProxyServer + "https://api.arte.tv/api/player/v2/config/de/" + surl + "?platform=ARTE_NEXT", null, false, successFunc, errorFunc, addheader) ;
rc = true;
}
}
}
}
Expand All @@ -54,7 +56,7 @@ export function checkAndQueryARTEMovieInfo(url, successFunc, errorFunc = null) {
* Checks if given url points to ZDF and triggers retrieval of movie info
* @return {boolean} True if ZDF movie URL, False if other
*/
export function checkAndQueryZDFMovieInfo(url, successFunc, errorFunc = null) {
export function checkAndQueryZDFMovieInfo(url, successFunc, errorFunc) {
let rc = false;
if (url && url.indexOf("www.zdf.de") > -1) {
// get ZDF Name id
Expand All @@ -71,7 +73,7 @@ export function checkAndQueryZDFMovieInfo(url, successFunc, errorFunc = null) {
* Checks if given url points to ZDF and triggers retrieval of movie info
* @return {boolean} True if ZDF movie URL, False if other
*/
export function checkAndQuery3SATMovieInfo(url, successFunc, errorFunc = null) {
export function checkAndQuery3SATMovieInfo(url, successFunc, errorFunc) {
let rc = false;
if (url && url.indexOf("www.3sat.de") > -1) {
// get ZDF Name id
Expand All @@ -85,7 +87,7 @@ export function checkAndQuery3SATMovieInfo(url, successFunc, errorFunc = null) {



// --------- ZDF/3SAT specific export functions -------------------------
// --------- ZDF/3SAT specific functions -------------------------
export function getZDF3SATImageURLFromJSON(json) {
try {
return json.teaserImageRef.layouts["768x432"];
Expand Down Expand Up @@ -148,41 +150,78 @@ export function getARTEExpiryStringFromJSON(json) {
return rstr;
}

const arteQualityMap = new Map([
["360p", 1],
["720p", 2],
["1080p", 3],
]);

export function getARTEStreamQuality(json, url) {
let maxidx = "";
let found = "";
try {
let maxheight = -1;
let sarr = json.data.attributes.streams;
function betterQuality(first, second) {
let x = arteQualityMap.has(first) ? arteQualityMap.get(first) : -1;
let y = arteQualityMap.has(second) ? arteQualityMap.get(second) : -1;
return x > y;
}

export function getARTEStreamQuality(json) {
let sarr = json;
let maxidx = -1;
let maxquality = -1;
let quality = "";
let omu = false;
let originalversion = false; // Originalfassung
let live = false;
for (const x in sarr) {
if (sarr[x].versions[0].shortLabel == "DE") {
quality = sarr[x].mainQuality.label;
if (betterQuality(quality, maxquality)) {
maxquality = quality;
maxidx = x;
}
}
}
if (maxidx == -1) {
for (const x in sarr) {
if (sarr[x].versionShortLibelle == "DE") {
if (sarr[x].url == url) {
found = x;
maxheight = sarr[x].height;
}
if (sarr[x].height > maxheight) {
maxheight = sarr[x].height;
if (sarr[x].versions[0].shortLabel == "OmU" && sarr[x].versions[0].label.indexOf("deutsch") > -1) {
quality = sarr[x].mainQuality.label;
if (betterQuality(quality, maxquality)) {
maxquality = quality;
maxidx = x;
omu = true;
}
}
}
if (found != "") {
if (sarr[found].height < maxheight) { // There is a better stream
found = -1;
}
else {
maxidx = found;
}
if (maxidx == -1) {
for (const x in sarr) {
if (sarr[x].versions[0].shortLabel == "OV") {
quality = sarr[x].mainQuality.label;
if (betterQuality(quality, maxquality)) {
maxquality = quality;
maxidx = x;
originalversion = true;
}
}
}
}
catch(err) {
// Do Nothing
if (maxidx == -1) {
for (const x in sarr) {
if (sarr[x].versions[0].shortLabel == "liveDE") {
quality = sarr[x].mainQuality.label;
if (betterQuality(quality, maxquality)) {
maxquality = quality;
maxidx = x;
live = true;
}
}
}
}
return {
"found": found != "",
"quality": maxidx == "" ? null : sarr[maxidx].height + "p",
"stream": maxidx == "" ? null : sarr[maxidx].url
"found" : (maxidx > -1),
"quality": maxidx > -1 ? sarr[maxidx].mainQuality.label : null,
"stream" : maxidx > -1 ? sarr[maxidx].url : null,
"omu" : omu,
"live" : live,
"ov" : originalversion
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ def proxy(url):
bmServerPort = cfgConfig.get('general', 'serverport', fallback = 8081)
#import pdb; pdb.set_trace()
cli = sys.modules['flask.cli']
cli.show_server_banner = lambda *x: click.echo("\n------------------------------------------------------\nDie Webseite kann jetzt im Browser unter der Adresse\n http://" + serverip + ":" + str(bmServerPort) +" geöffnet werden.\n------------------------------------------------------\n\n")
cli.show_server_banner = lambda *x: click.echo("\n------------------------------------------------------\nDie Webseite kann jetzt im Browser unter der Adresse\n http://" + serverip + ":" + str(bmServerPort) +" geoeffnet werden.\n------------------------------------------------------\n\n")

connex_app.run(port=bmServerPort, host=bmServerMode, debug=cfgConfig.getboolean("develop","enable_debug_mode", fallback=None))
2 changes: 1 addition & 1 deletion src/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ paths:
description: "Number of days before expiry day, a movie gets a warning"

example:
{ "name": "MyMediathek Server", "version": "0.9.0", "defaultplayer": -1, "players": [], "config": {"searchChannelInclude": ["ARD", "ZDF"], "searchTitleFilter" : [], "searchTopicFilter": [], "minMovieStateAge" : 183, "expiryWarningDays" : 5}}
{ "name": "MyMediathek Server", "version": "0.9.2", "defaultplayer": -1, "players": [], "config": {"searchChannelInclude": ["ARD", "ZDF"], "searchTitleFilter" : [], "searchTopicFilter": [], "minMovieStateAge" : 183, "expiryWarningDays" : 5}}


/info/config:
Expand Down

0 comments on commit 0255368

Please sign in to comment.