Skip to content

Commit 06b9e98

Browse files
v0.6.2.0 updates (#100)
* fix for #87 all public functions must specify an HTTP method * only Jellyfin Admins can use the HTTP Endpoints * Code cleanup, minor refactor before overhaul for easier readability * updated manifest * more code cleanup/refactoring * updated build scripts for ease-of-life * further cleaning. Fixed/modified error logging. Now no longer errors our on Virtual LocationType * found new params for newsletter. Began adding them in. Still need to update DB table, jsonobj class, etc * added popup for test email * updated build script * Alter DB table for new data/Added new data elements to DB. Clean up usless error messages. * code refactor (renamed elements) * code refactor (renamed class file) * updated .gitignore * More code refactoring. Now can dynamically add in new dynamic tags for future updates. Added new tags {} for newsletter * updated .gitignore * More code refactoring and adding in/fixing new tags. Updated default/template html code * Pulls in and sets Body/Entry HTML from template files * final updates for new tags * Updated build scripts and versioning * readme updated. build number bumped to 0.6.3.0. Manifest updated * updated checksum --------- Co-authored-by: Kilian von Pflugk <github@jumoog.io>
1 parent bb4a299 commit 06b9e98

26 files changed

+705
-173
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
*/.DS_Store
2-
Jellyfin.Plugin.Newsletters/bin/*
3-
Jellyfin.Plugin.Newsletters/obj/*
2+
Jellyfin.Plugin.Newsletters/bin
3+
Jellyfin.Plugin.Newsletters/obj
44
RELEASES
5+
artifacts
6+
Jellyfin.Plugin.Newsletters/newsletters/
7+
*.bak

BuildScripts/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ARG IMAGE_TAG=8
2+
FROM mcr.microsoft.com/dotnet/sdk:${IMAGE_TAG}.0
3+
4+
RUN apt-get update -y && \
5+
apt-get install python3 python3.11-venv zip unzip -y && \
6+
python3 -m venv venv && \
7+
. venv/bin/activate && \
8+
pip install jprm
9+
10+
RUN mkdir /.dotnet /.nuget /.local && chown 1000:1000 /.dotnet /.nuget /.local
11+
12+
USER 1000:1000

BuildScripts/build.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
#!/bin/bash
22
TAG=${1}
3-
if ! docker images -a | grep mcr.microsoft.com/dotnet/sdk${TAG}.0; then
4-
echo "Pulling dotnet:${TAG}.0 image"
5-
docker pull mcr.microsoft.com/dotnet/sdk:${TAG}.0
3+
4+
#### V1 ####
5+
6+
# if ! docker images -a | grep mcr.microsoft.com/dotnet/sdk${TAG}.0; then
7+
# echo "Pulling dotnet:${TAG}.0 image"
8+
# docker pull mcr.microsoft.com/dotnet/sdk:${TAG}.0
9+
# else
10+
# echo "Image already exists!"
11+
# fi
12+
13+
# docker run --name dotnet -it -v .:/Development mcr.microsoft.com/dotnet/sdk:${TAG}.0 /Development/BuildScripts/dotnetbuild.sh
14+
# docker rm dotnet
15+
16+
#### V2 ####
17+
IMAGE="pypi_dotnet"
18+
echo "Using image: '${IMAGE}:${TAG}.0'"
19+
if ! docker images -a | grep "${IMAGE}" | grep "${TAG}.0"; then
20+
echo "Generating '${IMAGE}:${TAG}.0' image"
21+
docker build -t ${IMAGE}:${TAG}.0 --build-arg IMAGE_TAG=8 ./BuildScripts/
622
else
723
echo "Image already exists!"
824
fi
925

10-
docker run --name dotnet -it -v .:/Development mcr.microsoft.com/dotnet/sdk:${TAG}.0 /Development/BuildScripts/dotnetbuild.sh
11-
docker rm dotnet
26+
docker run --name dotnet -it -v .:/Development ${IMAGE}:${TAG}.0 /Development/BuildScripts/dotnetbuild.sh "${2}"
27+
docker rm dotnet
28+
29+
# docker build -t pypi_dotnet:8.0 --build-arg IMAGE_TAG=8 .

BuildScripts/dotnetbuild.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
. venv/bin/activate
23
cd /Development
3-
dotnet build
4-
dotnet publish
5-
exit
4+
# dotnet build
5+
# dotnet publish
6+
7+
if [[ "${1}" == "prod" ]]; then
8+
export JELLYFIN_REPO="./Jellyfin.Plugin.Newsletters"
9+
export JELLYFIN_REPO_URL="https://github.com/Cloud9Developer/Jellyfin-Newsletter-Plugin/releases/download"
10+
./BuildScripts/jprm_build.sh
11+
cp ./Jellyfin.Plugin.Newsletters/manifest.json ./manifest.json
12+
else
13+
dotnet build
14+
# dotnet publish
15+
fi
16+
exit $?

BuildScripts/jprm_build.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2020 - Odd Strabo <oddstr13@openshell.no>
4+
#
5+
#
6+
# The Unlicense
7+
# =============
8+
#
9+
# This is free and unencumbered software released into the public domain.
10+
#
11+
# Anyone is free to copy, modify, publish, use, compile, sell, or
12+
# distribute this software, either in source code form or as a compiled
13+
# binary, for any purpose, commercial or non-commercial, and by any
14+
# means.
15+
#
16+
# In jurisdictions that recognize copyright laws, the author or authors
17+
# of this software dedicate any and all copyright interest in the
18+
# software to the public domain. We make this dedication for the benefit
19+
# of the public at large and to the detriment of our heirs and
20+
# successors. We intend this dedication to be an overt act of
21+
# relinquishment in perpetuity of all present and future rights to this
22+
# software under copyright law.
23+
#
24+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27+
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
28+
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30+
# OTHER DEALINGS IN THE SOFTWARE.
31+
#
32+
# For more information, please refer to <http://unlicense.org/>
33+
#
34+
35+
MY=$(dirname $(realpath -s "${0}"))
36+
JPRM="jprm"
37+
38+
DEFAULT_REPO_DIR="${MY}/test_repo"
39+
DEFAULT_REPO_URL="http://localhost:8080"
40+
41+
PLUGIN=${1:-${PLUGIN:-.}}
42+
43+
ARTIFACT_DIR=${ARTIFACT_DIR:-"${MY}/artifacts"}
44+
mkdir -p "${ARTIFACT_DIR}"
45+
46+
JELLYFIN_REPO=${JELLYFIN_REPO:-${DEFAULT_REPO_DIR}}
47+
JELLYFIN_REPO_URL=${JELLYFIN_REPO_URL:-${DEFAULT_REPO_URL}}
48+
49+
# Each segment of the version is a 16bit number.
50+
# Max number is 65535.
51+
VERSION_SUFFIX=${VERSION_SUFFIX:-$(date -u +%y%m.%d%H.%M%S)}
52+
53+
meta_version=$(grep -Po '^ *version: * "*\K[^"$]+' "${PLUGIN}/build.yaml")
54+
VERSION=${VERSION:-$(echo $meta_version)}
55+
56+
# !!! VERSION IS OVERWRITTEN HERE
57+
#VERSION="${meta_version}"
58+
59+
find "${PLUGIN}" -name project.assets.json -exec rm -v '{}' ';'
60+
61+
zipfile=$($JPRM --verbosity=debug plugin build "${PLUGIN}" --output="${ARTIFACT_DIR}" --version="${VERSION}") && {
62+
$JPRM --verbosity=debug repo add --url=${JELLYFIN_REPO_URL} "${JELLYFIN_REPO}" "${zipfile}"
63+
}
64+
rc=$?
65+
66+
# echo $JELLYFIN_REPO
67+
# package Templates/ as well
68+
cd ${MY}/../${JELLYFIN_REPO}
69+
zip -r ${zipfile} ./Templates
70+
echo "----------"
71+
echo "Contents in ${zipfile}"
72+
unzip -l ${zipfile}
73+
sed -i "s/github.com\/Cloud9Developer\/Jellyfin-Newsletter-Plugin\/releases\/download\/newsletters/github.com\/Cloud9Developer\/Jellyfin-Newsletter-Plugin\/releases\/download\/v${VERSION}/g" manifest.json
74+
75+
exit $rc

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 0.6.3.0
2+
- Major code refactoring.
3+
- Added additional data tags (see README.md)
4+
- Database updates for new available Tags.
5+
- Catch all for any missed tags in newsletter output.
6+
- Alert for "Test mail" button.
7+
- Better error logging/handling.
8+
- Added template files to Plugin directory
9+
- Plugin now pulls from these files as default values instead of hardcoded values in codebase
10+
111
# 0.6.2.1
212
- Minor security fix
313
- Cleaned codebase for easier readability

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.6.2.1</Version>
4-
<AssemblyVersion>0.6.2.1</AssemblyVersion>
5-
<FileVersion>0.6.2.1</FileVersion>
3+
<Version>0.6.3.0</Version>
4+
<AssemblyVersion>0.6.3.0</AssemblyVersion>
5+
<FileVersion>0.6.3.0</FileVersion>
66
</PropertyGroup>
77
</Project>

Jellyfin.Plugin.Newsletters/Configuration/PluginConfiguration.cs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using MediaBrowser.Model.Plugins;
34

@@ -13,6 +14,8 @@ public class PluginConfiguration : BasePluginConfiguration
1314
/// </summary>
1415
public PluginConfiguration()
1516
{
17+
Console.WriteLine("[NLP] :: Newsletter Plugin Starting..");
18+
1619
// set default options here
1720
DebugMode = false;
1821

@@ -26,59 +29,56 @@ public PluginConfiguration()
2629
ToAddr = string.Empty;
2730
FromAddr = "JellyfinNewsletter@donotreply.com";
2831
Subject = "Jellyfin Newsletter";
29-
// Body = string.Empty;
30-
// {EntryData}
31-
Body = @"<html>
32-
<div>
33-
<table style='margin-left: auto; margin-right: auto;'>
34-
<tr>
35-
<td width='100%' height='100%' style='vertical-align: top; background-color: #000000;'>
36-
<table id='InsertHere' name='MainTable' style='margin-left: auto; margin-right: auto; border-spacing: 0 5px; padding-left: 2%; padding-right: 2%; padding-bottom: 1%;'>
37-
<tr style='text-align: center;'>
38-
<td colspan='2'>
39-
<span>
40-
<h1 id='Title' style='color:#FFFFFF;'>Jellyfin Newsletter</h1>
41-
<h3 id='Date' style='color:#FFFFFF;'>2023-03-14</h3>
42-
</span>
43-
</td>
44-
</tr>
45-
<!-- Fill this in from code -->
46-
{EntryData}
47-
<!-- Fill that in from code -->
48-
</table>
49-
</td>
50-
</tr>
51-
</table>
52-
</div>
53-
</html>";
54-
55-
// Entry = string.Empty;
56-
// {ImageURL}
57-
// {Title}
58-
// {SeasonEpsInfo}
59-
// {SeriesOverview}
60-
Entry = @"<tr class='boxed' style='outline: thin solid #D3D3D3;'>
61-
<td class='lefttable' style='padding-right: 5%; padding-left: 2%; padding-top: 2%; padding-bottom: 2%;'>
62-
<img style='width: 200px; height: 300px;' src='{ImageURL}'>
63-
</td>
64-
<td class='righttable' style='vertical-align: top; padding-left: 5%; padding-right: 2%; padding-top: 2%; padding-bottom: 2%;'>
65-
<p>
66-
<div id='SeriesTitle' class='text' style='color: #FFFFFF; text-align: center;'>
67-
<h3>
68-
{Title}
69-
</h3>
70-
</div>
71-
<div class='text' style='color: #FFFFFF;'>
72-
{SeasonEpsInfo}
73-
</div>
74-
<hr>
75-
<div id='Description' class='text' style='color: #FFFFFF;'>
76-
{SeriesOverview}
77-
</div>
78-
</hr>
79-
</p>
80-
</td>
81-
</tr>";
32+
33+
// Attempt Dynamic set of Body and Entry HTML, set empty if failure occurs
34+
Body = string.Empty;
35+
Entry = string.Empty;
36+
37+
try
38+
{
39+
string[] dirs = Directory.GetDirectories(@".", "config/plugins/Jellyfin Newsletters_*.*.*.*", SearchOption.AllDirectories);
40+
string pluginDir = string.Empty;
41+
if (dirs.Length > 1)
42+
{
43+
Console.WriteLine($"[NLP] :: Found {dirs.Length} matches for plugin directory...");
44+
}
45+
else
46+
{
47+
foreach (string dir in dirs)
48+
{
49+
Console.WriteLine("[NLP] :: Plugin Directory is: {0}", dir);
50+
pluginDir = dir;
51+
break;
52+
}
53+
}
54+
55+
try
56+
{
57+
Body = File.ReadAllText($"{pluginDir}/Templates/template_modern_body.html");
58+
Console.WriteLine("[NLP] :: Body HTML set from Template file!");
59+
}
60+
catch (Exception ex)
61+
{
62+
Console.WriteLine("[NLP] :: Failed to set default Body HTML from Template file");
63+
Console.WriteLine(ex);
64+
}
65+
66+
try
67+
{
68+
Entry = File.ReadAllText($"{pluginDir}/Templates/template_modern_entry.html");
69+
Console.WriteLine("[NLP] :: Entry HTML set from Template file!");
70+
}
71+
catch (Exception ex)
72+
{
73+
Console.WriteLine("[NLP] :: Failed to set default Entry HTML from Template file");
74+
Console.WriteLine(ex);
75+
}
76+
}
77+
catch (Exception e)
78+
{
79+
Console.WriteLine("[NLP] :: [ERR] Failed to locate/set html body from template file..");
80+
Console.WriteLine(e);
81+
}
8282

8383
// default Scraper config
8484
ApiKey = string.Empty;

Jellyfin.Plugin.Newsletters/Configuration/configPage.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@
291291
});
292292
Dashboard.hideLoadingMsg();
293293
e.preventDefault();
294+
alert("Test email sent!");
294295
return false;
295296
});
296297

0 commit comments

Comments
 (0)