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

[FR] need a way to order by playlist order rather than upload order #309

Closed
DarkVirtue opened this issue Jul 13, 2024 · 12 comments · Fixed by #320
Closed

[FR] need a way to order by playlist order rather than upload order #309

DarkVirtue opened this issue Jul 13, 2024 · 12 comments · Fixed by #320
Assignees
Labels

Comments

@DarkVirtue
Copy link

Describe the bug
The {{ season_episode_index_from_date }} template ends up misnumbering items in a playlist compared to the order in the playlist.

To Reproduce
For example, in the SGDQ 2024 playlist, the first few videos are:

  1. Preshow
  2. Yoshi's Story
  3. Minecraft Dungeons
  4. Mega Man 9

When using {{ season_episode_index_from_date }}, however, the numbering is like this:

's2024e063000 - Preshow - Summer Games Done Quick 2024.mp4'
's2024e063001 - Minecraft Dungeons by Shockwve in 27_18 - Summer Games Done Quick 2024.mp4'
's2024e063002 - Mega Man 9 by Slurpeeninja in 41_03 - Summer Games Done Quick 2024.mp4'
"s2024e070100 - Yoshi's Story by Dan Salvato in 1_46_40 - Summer Games Done Quick 2024.mp4"
's2024e070101 - Ratchet & Clank by marathonman in 55_29 - Summer Games Done Quick 2024.mp4'
's2024e070102 - Splatoon 3: Side Order by TonesBalones in 28_43 - Summer Games Done Quick 2024.mp4'

Compared to the playlist, this is 1 3 4 2 5 6 ordering.

Expected behavior
The issue seems to be the first three videos, as downloaded, are indexed 000, 001, and 002, while the rest are indexed as 100, 101, 102, etc.

@kieraneglin
Copy link
Owner

Hey there! Thanks for the report (:

This is expected in the sense that season_episode_index_from_date is working as intended. Some of the videos were uploaded on June 30th (0630XX) and others were uploaded on July 1st (0701XX). There is a disconnect in that the playlist order is not the same as the upload order but nothing is "broken" per se.

That said, I completely get that this isn't the behaviour you were expecting! I'll see if I can come up with a different solution for this and get back to you

@kieraneglin kieraneglin changed the title [Triage] season_episode_index_from_date does not match playlist order [FR] need a way to order by playlist order rather than upload order Jul 15, 2024
@kieraneglin
Copy link
Owner

I think I have something workable in #318. tl;dr is the new output template would be /shows/{{ source_custom_name }}/{{ static_season__episode_by_index }} - {{ title }}.{{ ext }}

This builds off the work in #315 but the caveat is that this change wouldn't be retroactive for existing media - you'd have to delete and re-download that source to take advantage of this new output template.

Anyway, I'm going to test it some more in my local setup and, once I'm happy with it, I'll push an update including those changes later today. I'll let you know!

@kieraneglin
Copy link
Owner

After my testing I'm happy with how that works! I'll send out that update shortly and it should be available within an hour

@DarkVirtue
Copy link
Author

Thanks for the quick turnaround on this!

The naming scheme looks pretty good:
{{ static_season__episode_by_index }} - {{ title }}.{{ ext }} results in files numbered like these:

s01e1 - Preshow - Summer Games Done Quick 2024.mp4
s01e2 - Yoshi's Story by Dan Salvato in 1_46_40 - Summer Games Done Quick 2024.mp4
s01e3 - Minecraft Dungeons by Shockwve in 27_18 - Summer Games Done Quick 2024.mp4
s01e4 - Mega Man 9 by Slurpeeninja in 41_03 - Summer Games Done Quick 2024.mp4
s01e5 - Ratchet & Clank by marathonman in 55_29 - Summer Games Done Quick 2024.mp4
s01e6 - Splatoon 3: Side Order by TonesBalones in 28_43 - Summer Games Done Quick 2024.mp4
s01e7 - Pokémon Violet by ThomasPatrickWX in 1_52_16 - Summer Games Done Quick 2024.mp4
s01e8 - Halo 2 by Zoo in 1_23_20 - Summer Games Done Quick 2024.mp4
s01e9 - Tomb Raider I Remastered by Beckski in 1_12_14 - Summer Games Done Quick 2024.mp4
s01e10 - Enter the Gungeon Race by RadRingtail & DanTheVP in 28_28 - Summer Games Done Quick 2024.mp4

Would it be possiblet to get zero-padding on the episode number?


Also, while the indexed episode numbering is great, it looks like it's not reflected in generated .nfo files. For example:

cat s01e1\ -\ Preshow\ -\ Summer\ Games\ Done\ Quick\ 2024.nfo 
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<episodedetails>
  <title>Preshow - Summer Games Done Quick 2024</title>
  <showtitle>Games Done Quick</showtitle>
  <uniqueid type="youtube" default="true">vZ9glfRyvOk</uniqueid>
  <plot>Preshow starts at 0:00
Opening ceremony with Doctors Without Borders starts at 28:09

This speedrun was recorded during Summer Games Done Quick 2024, a week long charity speedrun marathon raising money for Doctors Without Borders. Summer Games Done Quick 2024 is just one of the many charity marathons organized by Summer Games Done Quick. For more information on Summer Games Done Quick 2024, find us at: https://gamesdonequick.com/

Looking for live updates?

Follow us on Twitter: https://twitter.com/GamesDoneQuick
Like us on Facebook: http://www.facebook.com/GamesDoneQuick
Follow us on Instagram: https://instagram.com/gamesdonequick</plot>
  <aired>2024-06-30 00:00:00Z</aired>
  <season>2024</season>
  <episode>0630</episode>
  <genre>YouTube</genre>
</episodedetails>

The <season> and <episode> tags disagree with the file names and result in date collisions. Jellyfin was very confused.

@kieraneglin
Copy link
Owner

Good call on the NFO issue! I'll look into it

@kieraneglin
Copy link
Owner

Fixed! I want to do some more testing on it later today so that fix will likely go out tomorrow

@kieraneglin
Copy link
Owner

This is going out and will be up in ~30 mins! Just a heads up that this is also not a retroactive change so you may have to delete + re-download that source. Sorry about that!

@DarkVirtue
Copy link
Author

Thanks! I've cleared and re-downloaded the above playlist with the new template option. It's almost perfect. For some reason, two videos were downloaded twice - once with the correct index number, and once with s01e00:

s01e00 - Yellow Taxi Goes Vroom by Forrest and Ouro in 29_18 - Summer Games Done Quick 2024.mp4
s01e120 - Yellow Taxi Goes Vroom by Forrest and Ouro in 29_18 - Summer Games Done Quick 2024.mp4

and

s01e00 - Super Mario 64 Randomizer Blindfolded by Bubzia in 43_39 - Summer Games Done Quick 2024.mp4
s01e143 - Super Mario 64 Randomizer Blindfolded by Bubzia in 43_39 - Summer Games Done Quick 2024.mp4

@kieraneglin
Copy link
Owner

hmm. I think that may be related to #166 (which is related to #139 which is waiting for a PR I've made for yt-dlp to be merged). Would you mind going to one of these videos in the Pinchflat UI > Actions > Copy JSON and post that here? That would let me confirm for sure

@DarkVirtue
Copy link
Author

{
  "id": 13409,
  "description": "Runner introduction starts at 0:00
Run starts at 0:31
Commentary is provided by moogle and darkterrex 
Argick is host

This speedrun was recorded during Summer Games Done Quick 2024, a week long charity speedrun marathon raising money for Doctors Without Borders. Summer Games Done Quick 2024 is just one of the many charity marathons organized by Games Done Quick. For more information on Summer Games Done Quick 2024, find us at: https://gamesdonequick.com/

Looking for live updates?

Follow us on Twitter: https://twitter.com/GamesDoneQuick
Like us on Facebook: http://www.facebook.com/GamesDoneQuick
Follow us on Instagram: https://instagram.com/gamesdonequick",
  "title": "Yellow Taxi Goes Vroom by Forrest and Ouro in 29:18 - Summer Games Done Quick 2024",
  "source": {
    "id": 8,
    "description": null,
    "uuid": "ad49fd44-5582-484e-a0ca-5ed38b043084",
    "inserted_at": "2024-07-18T23:22:36Z",
    "updated_at": "2024-07-23T03:05:43Z",
    "media_profile": {
      "id": 4,
      "name": "Shows",
      "inserted_at": "2024-07-16T22:19:36Z",
      "updated_at": "2024-07-18T23:21:49Z",
      "output_path_template": "/shows/{{ source_custom_name }}/{{ static_season__episode_by_index }} - {{ title }}.{{ ext }}",
      "preferred_resolution": "720p",
      "sponsorblock_categories": [
        "sponsor",
        "selfpromo"
      ],
      "sponsorblock_behaviour": "remove",
      "download_thumbnail": true,
      "embed_thumbnail": true,
      "download_auto_subs": false,
      "download_subs": true,
      "embed_subs": true,
      "sub_langs": "en",
      "download_metadata": false,
      "embed_metadata": true,
      "download_nfo": true,
      "download_source_images": true,
      "livestream_behaviour": "exclude",
      "redownload_delay_days": 1,
      "shorts_behaviour": "exclude"
    },
    "nfo_filepath": "/downloads/shows/SGDQ 2024/tvshow.nfo",
    "original_url": "https://www.youtube.com/playlist?list=PLz8YL4HVC87VobIaDgy7SZ4Q-QivCYbyP",
    "download_media": true,
    "media_profile_id": 4,
    "custom_name": "SGDQ 2024",
    "collection_id": "PLz8YL4HVC87VobIaDgy7SZ4Q-QivCYbyP",
    "collection_name": "Summer Games Done Quick 2024",
    "collection_type": "playlist",
    "download_cutoff_date": null,
    "title_filter_regex": null,
    "banner_filepath": null,
    "fanart_filepath": null,
    "poster_filepath": "/downloads/shows/SGDQ 2024/poster.jpg",
    "series_directory": "/downloads/shows/SGDQ 2024",
    "fast_index": false,
    "last_indexed_at": "2024-07-23T03:05:43Z",
    "index_frequency_minutes": 1440,
    "output_path_template_override": null,
    "retention_period_days": null
  },
  "uuid": "5435a6d3-e89f-47ed-939e-2a1eeca93287",
  "inserted_at": "2024-07-18T23:36:32Z",
  "updated_at": "2024-07-19T01:58:51Z",
  "source_id": 8,
  "matching_search_term": null,
  "subtitle_filepaths": [],
  "culled_at": null,
  "duration_seconds": 1902,
  "livestream": false,
  "media_downloaded_at": "2024-07-19T01:58:45Z",
  "media_filepath": "/downloads/shows/SGDQ 2024/Season 1/s01e00 - Yellow Taxi Goes Vroom by Forrest and Ouro in 29_18 - Summer Games Done Quick 2024.mp4",
  "media_id": "e48D3iHQ8e4",
  "media_redownloaded_at": null,
  "media_size_bytes": 686706596,
  "metadata_filepath": null,
  "nfo_filepath": "/downloads/shows/SGDQ 2024/Season 1/s01e00 - Yellow Taxi Goes Vroom by Forrest and Ouro in 29_18 - Summer Games Done Quick 2024.nfo",
  "original_url": "https://www.youtube.com/watch?v=e48D3iHQ8e4",
  "playlist_index": 0,
  "prevent_culling": false,
  "prevent_download": false,
  "short_form_content": false,
  "thumbnail_filepath": "/downloads/shows/SGDQ 2024/Season 1/s01e00 - Yellow Taxi Goes Vroom by Forrest and Ouro in 29_18 - Summer Games Done Quick 2024-thumb.jpg",
  "upload_date_index": 19,
  "uploaded_at": "2024-07-05T22:28:16Z"
}

@kieraneglin
Copy link
Owner

Very strange! There's logic in place to prevent a video with the same media_id from being added to a source multiple times (ie: no duplicate videos allowed per-source). This constraint is implemented at the database level so it's very unlikely that it made a mistake, so to speak.

Is there any chance that some of these are from a different source? Would you mind posting the JSON for the media item that had the correct s01e120 filepath?

@DarkVirtue
Copy link
Author

The above was the only instance of that item in the Pinchflat UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants