Cloud9Developer / Jellyfin-Newsletter-Plugin

GNU General Public License v3.0
66 stars 7 forks source link

{ImageURL} return 403 #70

Open Hani-K opened 6 months ago

Hani-K commented 6 months ago

Issue

For some reason, when sending newsletter, all images return 403. This happens with both Local JF Hosting and Imgur.

How to replicate?

  1. Trigger a new Newsletter event by either uploading new data or changing a name of existing data on the drive.
  2. Update Jellyfin media to see the new change. Jellyfin dashboard > scheduled tasks > scan media library.
  3. Now, prepare the EntryData Html if not already prepared.
  4. Update Newsletter entries. Jellyfin dashboard > scheduled tasks > Filesystem scraper.
  5. Send Newsletter. Jellyfin dashboard > scheduled tasks > Email Newsletter

Proof of concept

My config:

image

I modified the EntryData to troubleshoot. My EntryData Html:

<tr class='boxed' style='outline: thin solid #D3D3D3;'> 
    <td class='lefttable' style='padding-right: 5%; padding-left: 2%; padding-top: 2%; padding-bottom: 2%;'> 
        <h3>img style='width: 200px; height: 300px;' src='{ImageURL}'</h3>
        <img style='width: 200px; height: 300px;' src='{ImageURL}'>
        <h3>ImageURL return</h3>
        <h4>{ImageURL}</h4>
        <h3>Actual image link</h3>
        <img style='width: 200px; height: 300px;' src='https://DOMAIN/Items/53ffb968191ebbe94439add99e8b6fbb/Images/Primary'>
    </td> 

Log when using local JF hosting

[NLP]: [2023-12-25] :: [11:55:10] - [INFO] Gathering Data...
[NLP]: [2023-12-25] :: [11:55:10] - [INFO] Parsing Series..
[NLP]: [2023-12-25] :: [11:55:10] - [INFO] Series Scan Size: 1007
[NLP]: [2023-12-25] :: [11:55:10] - [INFO] Parsing Movie..
[NLP]: [2023-12-25] :: [11:55:10] - [INFO] Movie Scan Size: 365
[NLP]: [2023-12-25] :: [11:55:10] - [ERR] Encountered an error parsing Season Number for: /mnt/rust/media/data/media/movies/The Equalizer 3 (2023) [imdbid-tt17024450]/The Equalizer 3 (2023) [imdbid-tt17024450] - [Bluray-1080p][DTS-HD MA 5.1][x264]-MTeam8.mkv
[NLP]: [2023-12-25] :: [11:55:10] - [ERR] System.FormatException: Input string was not in a correct format.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at System.Int32.Parse(String s, IFormatProvider provider)
   at Jellyfin.Plugin.Newsletters.Scripts.SCRAPER.Scraper.BuildObjs(List`1 items, String type)
[NLP]: [2023-12-25] :: [11:55:11] - [INFO] Newsletter will be saved to: /var/cache/jellyfin/temp/Newsletters/myNewsletters/2023-12-25_Newsletter.html
[NLP]: [2023-12-25] :: [11:55:12] - [INFO] Saving HTML file
[NLP]: [2023-12-25] :: [11:55:12] - [INFO] Appending NewsletterData for Current Newsletter Cycle to Archive Database..

Log when using imgur

[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Opening Database: /var/lib/jellyfin/data/newsletters.db
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Creating Tables...
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Executing SQL Statement: create table if not exists CurrRunData (Filename TEXT NOT NULL,Title TEXT,Season INT,Episode INT,SeriesOverview TEXT,ImageURL TEXT,ItemID TEXT,PosterPath TEXT,Type TEXT,PRIMARY KEY (Filename));
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Alter Table no longer required as of V0.5.1!
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Executing SQL Statement: create table if not exists CurrNewsletterData (Filename TEXT NOT NULL,Title TEXT,Season INT,Episode INT,SeriesOverview TEXT,ImageURL TEXT,ItemID TEXT,PosterPath TEXT,Type TEXT,PRIMARY KEY (Filename));
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Alter Table no longer required as of V0.5.1!
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Executing SQL Statement: create table if not exists ArchiveData (Filename TEXT NOT NULL,Title TEXT,Season INT,Episode INT,SeriesOverview TEXT,ImageURL TEXT,ItemID TEXT,PosterPath TEXT,Type TEXT,PRIMARY KEY (Filename));
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Alter Table no longer required as of V0.5.1!
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Done Init of tables
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Running Query: SELECT COUNT(*) FROM CurrNewsletterData;
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Closing Database: /var/lib/jellyfin/data/newsletters.db
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Sending out mail!
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Newsletter will be saved to: /var/cache/jellyfin/temp/Newsletters/myNewsletters/2023-12-25_Newsletter.html
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Opening Database: /var/lib/jellyfin/data/newsletters.db
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Creating Tables...
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Executing SQL Statement: create table if not exists CurrRunData (Filename TEXT NOT NULL,Title TEXT,Season INT,Episode INT,SeriesOverview TEXT,ImageURL TEXT,ItemID TEXT,PosterPath TEXT,Type TEXT,PRIMARY KEY (Filename));
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Alter Table no longer required as of V0.5.1!
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Executing SQL Statement: create table if not exists CurrNewsletterData (Filename TEXT NOT NULL,Title TEXT,Season INT,Episode INT,SeriesOverview TEXT,ImageURL TEXT,ItemID TEXT,PosterPath TEXT,Type TEXT,PRIMARY KEY (Filename));
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Alter Table no longer required as of V0.5.1!
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Executing SQL Statement: create table if not exists ArchiveData (Filename TEXT NOT NULL,Title TEXT,Season INT,Episode INT,SeriesOverview TEXT,ImageURL TEXT,ItemID TEXT,PosterPath TEXT,Type TEXT,PRIMARY KEY (Filename));
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Alter Table no longer required as of V0.5.1!
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Done Init of tables
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Running Query: SELECT * FROM CurrNewsletterData;
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Closing Database: /var/lib/jellyfin/data/newsletters.db
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Saving HTML file
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Appending NewsletterData for Current Newsletter Cycle to Archive Database..
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Executing SQL Statement: INSERT INTO ArchiveData SELECT * FROM CurrNewsletterData;
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Executing SQL Statement: DELETE FROM CurrNewsletterData;
[NLP]: [2023-12-25] :: [12:19:44] - [INFO] Database lock file does not exist. Database is not use: /var/lib/jellyfin/data/newsletters.db.lock

Result

image

Setup

Jellyfin 10.8.13 Installed on a standalone Debian GNU/Linux 12 (bookworm) LXC container

Cloud9Developer commented 1 month ago

Is the imgur or local hosting serving the broken image?

Hani-K commented 1 month ago

Not entirely sure, if both functionalities are broken and return a string that cannot be parsed as an image, which leads to 403. Or if the {ImageURL} var itself is broken and is not processing the links properly and resulting in 403.

But if you match the EntryData Html to the Result, line by line; You could see that the {ImageURL} variable itself returns 403, so I would start fom there.

Cloud9Developer commented 1 month ago

one thing to note here: if a series get's scanned in, all subsequent episodes will use the same image hosting method as the original (so long as there exists a url for the series prior). This is a task I have in my backlog to fix (database refreshing).

So for now, could you try to follow these steps just to see if it's something with the DB as is?

the newsletters.db file lives in your jellyfin's data directory.

/PATH/TO/JELLYFIN/config/data/newsletters.db

Try with imgur first I, then repeat and try with local hosting. See if you get different results and let me know.

--- Also, you can compare the newsletter in the email with the physical copy saved into Jellyfin's cache directory:

/PATH/TO/JELLYFIN/cache/temp/Newsletters