McCloudS / subgen

Autogenerate subtitles using OpenAI Whisper Model via Jellyfin, Plex, Emby, Tautulli, or Bazarr
MIT License
532 stars 48 forks source link

Jellyfin userid #19

Closed ManifestFailure closed 10 months ago

ManifestFailure commented 10 months ago

This creates a new variable called jellyfin_userid near the start of the file, and just before the api call is made, checks to see if the string is empty or not. If it's empty, it fetches the admin userid to store in the new variable and is used for all subsequent api requests.

Quick fix for https://github.com/McCloudS/subgen/issues/15

McCloudS commented 10 months ago

Here's a response, {"ServerId":"5c79aa3c0f24484fb6c4f544005f3803","ServerName":"4e6ba6986d31","ServerVersion":"10.8.11","ServerUrl":"","NotificationType":"PlaybackStart","Timestamp":"2023-10-25T19:49:32.5846779-07:00","UtcTimestamp":"2023-10-26T02:49:32.5846835Z","Name":"How Poopy Got His Poop Back","Overview":"Rick and friends have a wild night with Mr. Poopybutthole during a rough time in his life.","Tagline":"","ItemId":"6de27c449bd859403bfce9851bdc27c7","ItemType":"Episode","RunTimeTicks":13401709568,"RunTime":"00:22:20","Year":2013,"SeriesName":"Rick and Morty","SeasonNumber":7,"SeasonNumber00":"07","SeasonNumber000":"007","EpisodeNumber":1,"EpisodeNumber00":"01","EpisodeNumber000":"001","Provider_tvdb":"9971637","Provider_imdb":"tt28244512","Video_0_Title":"MiNX - Small HD episodes - 720p - HEVC - SDR","Video_0_Type":"Video","Video_0_Codec":"hevc","Video_0_Profile":"Main","Video_0_Level":93,"Video_0_Height":720,"Video_0_Width":1280,"Video_0_AspectRatio":"16:9","Video_0_Interlaced":false,"Video_0_FrameRate":23.976025,"Video_0_VideoRange":"SDR","Video_0_ColorSpace":"bt709","Video_0_ColorTransfer":"bt709","Video_0_ColorPrimaries":"bt709","Video_0_PixelFormat":"yuv420p","Video_0_RefFrames":1,"Audio_0_Title":"MiNX - Small HD episodes - English - AAC - Stereo - Default","Audio_0_Type":"Audio","Audio_0_Language":"eng","Audio_0_Codec":"aac","Audio_0_Channels":2,"Audio_0_Bitrate":192000,"Audio_0_SampleRate":48000,"Audio_0_Default":true,"Subtitle_0_Title":"MiNX - Small HD episodes - English - Default - SUBRIP","Subtitle_0_Type":"Subtitle","Subtitle_0_Language":"eng","Subtitle_0_Codec":"subrip","Subtitle_0_Default":true,"Subtitle_0_Forced":false,"Subtitle_0_External":false,"Subtitle_1_Title":"English [SDH] - SUBRIP","Subtitle_1_Type":"Subtitle","Subtitle_1_Language":"eng","Subtitle_1_Codec":"subrip","Subtitle_1_Default":false,"Subtitle_1_Forced":false,"Subtitle_1_External":false,"Subtitle_2_Title":"Bulgarian (Bulgaria) - SUBRIP","Subtitle_2_Type":"Subtitle","Subtitle_2_Language":"bul","Subtitle_2_Codec":"subrip","Subtitle_2_Default":false,"Subtitle_2_Forced":false,"Subtitle_2_External":false,"Subtitle_3_Title":"Croatian (Croatia) - SUBRIP","Subtitle_3_Type":"Subtitle","Subtitle_3_Language":"hrv","Subtitle_3_Codec":"subrip","Subtitle_3_Default":false,"Subtitle_3_Forced":false,"Subtitle_3_External":false,"Subtitle_4_Title":"Czech (Czechia) - SUBRIP","Subtitle_4_Type":"Subtitle","Subtitle_4_Language":"cze","Subtitle_4_Codec":"subrip","Subtitle_4_Default":false,"Subtitle_4_Forced":false,"Subtitle_4_External":false,"Subtitle_5_Title":"Danish - SUBRIP","Subtitle_5_Type":"Subtitle","Subtitle_5_Language":"dan","Subtitle_5_Codec":"subrip","Subtitle_5_Default":false,"Subtitle_5_Forced":false,"Subtitle_5_External":false,"Subtitle_6_Title":"Dutch - SUBRIP","Subtitle_6_Type":"Subtitle","Subtitle_6_Language":"dut","Subtitle_6_Codec":"subrip","Subtitle_6_Default":false,"Subtitle_6_Forced":false,"Subtitle_6_External":false,"Subtitle_7_Title":"European Spanish - SUBRIP","Subtitle_7_Type":"Subtitle","Subtitle_7_Language":"spa","Subtitle_7_Codec":"subrip","Subtitle_7_Default":false,"Subtitle_7_Forced":false,"Subtitle_7_External":false,"Subtitle_8_Title":"Finnish - SUBRIP","Subtitle_8_Type":"Subtitle","Subtitle_8_Language":"fin","Subtitle_8_Codec":"subrip","Subtitle_8_Default":false,"Subtitle_8_Forced":false,"Subtitle_8_External":false,"Subtitle_9_Title":"Hungarian - SUBRIP","Subtitle_9_Type":"Subtitle","Subtitle_9_Language":"hun","Subtitle_9_Codec":"subrip","Subtitle_9_Default":false,"Subtitle_9_Forced":false,"Subtitle_9_External":false,"Subtitle_10_Title":"Latin America Spanish - SUBRIP","Subtitle_10_Type":"Subtitle","Subtitle_10_Language":"spa","Subtitle_10_Codec":"subrip","Subtitle_10_Default":false,"Subtitle_10_Forced":false,"Subtitle_10_External":false,"Subtitle_11_Title":"Macedonian (North Macedonia) - SUBRIP","Subtitle_11_Type":"Subtitle","Subtitle_11_Language":"mac","Subtitle_11_Codec":"subrip","Subtitle_11_Default":false,"Subtitle_11_Forced":false,"Subtitle_11_External":false,"Subtitle_12_Title":"Norwegian - SUBRIP","Subtitle_12_Type":"Subtitle","Subtitle_12_Language":"nor","Subtitle_12_Codec":"subrip","Subtitle_12_Default":false,"Subtitle_12_Forced":false,"Subtitle_12_External":false,"Subtitle_13_Title":"Polish - SUBRIP","Subtitle_13_Type":"Subtitle","Subtitle_13_Language":"pol","Subtitle_13_Codec":"subrip","Subtitle_13_Default":false,"Subtitle_13_Forced":false,"Subtitle_13_External":false,"Subtitle_14_Title":"Portuguese - SUBRIP","Subtitle_14_Type":"Subtitle","Subtitle_14_Language":"por","Subtitle_14_Codec":"subrip","Subtitle_14_Default":false,"Subtitle_14_Forced":false,"Subtitle_14_External":false,"Subtitle_15_Title":"Portuguese Brazilian - SUBRIP","Subtitle_15_Type":"Subtitle","Subtitle_15_Language":"por","Subtitle_15_Codec":"subrip","Subtitle_15_Default":false,"Subtitle_15_Forced":false,"Subtitle_15_External":false,"Subtitle_16_Title":"Romanian (Romania) - Rum - SUBRIP","Subtitle_16_Type":"Subtitle","Subtitle_16_Language":"rum","Subtitle_16_Codec":"subrip","Subtitle_16_Default":false,"Subtitle_16_Forced":false,"Subtitle_16_External":false,"Subtitle_17_Title":"Serbian (Latin, Serbia) - SUBRIP","Subtitle_17_Type":"Subtitle","Subtitle_17_Language":"srp","Subtitle_17_Codec":"subrip","Subtitle_17_Default":false,"Subtitle_17_Forced":false,"Subtitle_17_External":false,"Subtitle_18_Title":"Slovenian (Slovenia) - SUBRIP","Subtitle_18_Type":"Subtitle","Subtitle_18_Language":"slv","Subtitle_18_Codec":"subrip","Subtitle_18_Default":false,"Subtitle_18_Forced":false,"Subtitle_18_External":false,"Subtitle_19_Title":"Swedish - SUBRIP","Subtitle_19_Type":"Subtitle","Subtitle_19_Language":"swe","Subtitle_19_Codec":"subrip","Subtitle_19_Default":false,"Subtitle_19_Forced":false,"Subtitle_19_External":false,"PlaybackPositionTicks":1000000,"PlaybackPosition":"00:00:00","MediaSourceId":"6de27c449bd859403bfce9851bdc27c7","IsPaused":false,"IsAutomated":false,"DeviceId":"TW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTVfNykgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzExNy4wLjAuMCBTYWZhcmkvNTM3LjM2fDE2OTgwOTg4NTIwMTI1","DeviceName":"Chrome","ClientName":"Jellyfin Web","NotificationUsername":"scott","UserId":"082449762a8d4200b70898ef9a9e0a0b"}

Is it worth doing your other recommendation of just pulling the UserId straight from this so it 'matches' the person playing the file?

ManifestFailure commented 10 months ago

This change is a quick way to get the admin userId that we know would have access to all Libraries on the server. It gets around the issue where my first user from the API request only has limited access to the library.

I think a large portion of the script would need to be changed in regards to adding the ability to scan the library and have it generate the files for pre-existing items. May be worth applying this fix or something similar to get around the issue where the first user may not have access to the Item request, and then looking into more flexible options as part of this Issue. https://github.com/McCloudS/subgen/issues/18

McCloudS commented 10 months ago

I kept getting: UnboundLocalError: cannot access local variable 'jellyfin_userid' where it is not associated with a value

Added global jellyfin_userid above it's execution and it fixed it for me.