Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Plex Directory Issue/Question #74

Closed
richardgetz opened this issue Aug 18, 2022 · 28 comments
Closed

Plex Directory Issue/Question #74

richardgetz opened this issue Aug 18, 2022 · 28 comments

Comments

@richardgetz
Copy link

While all the episodes show up as expected, I also see them all as movies. Any advice or ideas on how to keep them separated per advice here? https://support.plex.tv/articles/naming-and-organizing-your-tv-show-files/

@itsToggle
Copy link
Owner

That's strange.. My plex server is able to separate them correctly, it especially doesn't map the same media file both as a movie and an episode. I'm not even sure that plex can map the same file twice - are you sure that the episodes mapped as movies aren't specials which don't follow the episode naming convention (some.show.S01E01)?

When I add a torrent that contains special episodes which then show up as movies, I simply merge them all together as a "movie" called "specials".

If you are using realdebrid, I could implement some form of show/movie seperation for my rclone fork. This would work by looking for season or episode handles (S01 or S01E01) in the torrents files and then artificially placing the torrents in a "show", "movie" or "default" folder for content that couldn't be matched. Is that something you would be interested in?

@richardgetz
Copy link
Author

What Plex agent(s) are you using? I downloaded The Office as an example and it showed up in both. In TV Shows it looks normal, but in Movies it splits them all out individually. And yes I am using real debrid.

Separately, after it downloaded my Trakt watchlist shows became unavailable. After some digging I think it's because it can't see the files in WebDAV. Do you know if there's a hard cap on the realdebrid side or if I have something possibly mounted incorrectly?

@richardgetz
Copy link
Author

richardgetz commented Aug 19, 2022

Unless you fork handles for that issue specifically. I was using the default rclone WebDAV setup as I'm running on a Synology and wasn't sure if yours would work out of the box.

@itsToggle
Copy link
Owner

Im using Plex's own metadata agent's, the ones that are turned on by default.

I think I know what might be happening. I thought I mentioned this in the readme, but I just checked and I didn't:

Any chance you added both the realdebrid "links" and "torrents" folder to your Plex library? "torrents" is the only folder you should mount. The "links" folder contains the last ~200 direct links to the torrents files. This would explain why Plex can map files twice and why some files disappear.

So either change the Plex library folders to only the "torrents" folder, or change your mounting command to this: "rclone mount your-remote:torrents X: --dir-cache-time 10s --vfs-cache-mode full"

You could also switch to my own version of rclone (as detailed in the readme)

@richardgetz
Copy link
Author

Yes I had links mounted as well. I'll change that and see if I can switch to your version of rclone to determine if that fixes my issue. I appreciate your help, thank you!

@richardgetz
Copy link
Author

I am on synology attempting to run this and it hangs. Any recommendations for what I should try first? Rclone in this case is actually your rclone-linux I just renamed it. I was able to create the configuration without issue.

rclone mount RealDebrid:torrents /volume1/docker/plex/media/rd-torrents/: --config=/volume1/rclone.conf --cache-dir=/volume1/docker/plex/cache --vfs-cache-mode full --allow-other --dir-cache-time 10s

@itsToggle
Copy link
Owner

What happens after you run the command? Is the terminal simply not responding any more?

If so, check that the directory you want to mount in is empty first. Also, add the tag "--deamon", to run rclone in the background.

Ive also just released an updated version of the rclone fork (https://github.com/itsToggle/rclone_RD/releases/tag/v1.58.1-rd.1.5)

@richardgetz
Copy link
Author

Pulled the new version and am still having the same issue. Assuming you meant --daemon and that was a typo, it produces the same issue, just hangs and never mounts. Confirmed there is nothing where I am trying to mount, including no hidden files.

@itsToggle
Copy link
Owner

when using my fork, could you run the command without the ":torrents" remote folder specification and without the ":" at the end of the destination? e.g.: "rclone mount RealDebrid: /volume1/docker/plex/media/rd-torrents/ --config=/volume1/rclone.conf --cache-dir=/volume1/docker/plex/cache --vfs-cache-mode full --allow-other --dir-cache-time 10s"

If that still doesnt work, make sure there is no mount running in that directory at the moment by running the command "fusermount -u /volume1/docker/plex/media/rd-torrents/"

Perhaps also check that all rclone processes are closed by running "top"

@richardgetz
Copy link
Author

Okay I got it! I removed the explicit reference to the torrent file and will instead only point Plex at the torrents folder. Here is my command for others who stumble upon this in the future. Using rclone-linux from your fork, Synology DS920+ DSM 7.1.

sudo rclone mount RealDebrid: /volume1/docker/plex/media/rd-torrents/ --config=/volume1/rclone.conf --cache-dir=/volume1/docker/plex/cache --vfs-cache-mode full --allow-other --dir-cache-time 10s --daemon

@richardgetz
Copy link
Author

when using my fork, could you run the command without the ":torrents" remote folder specification and without the ":" at the end of the destination? e.g.: "rclone mount RealDebrid: /volume1/docker/plex/media/rd-torrents/ --config=/volume1/rclone.conf --cache-dir=/volume1/docker/plex/cache --vfs-cache-mode full --allow-other --dir-cache-time 10s"

If that still doesnt work, make sure there is no mount running in that directory at the moment by running the command "fusermount -u /volume1/docker/plex/media/rd-torrents/"

Perhaps also check that all rclone processes are closed by running "top"

when using my fork, could you run the command without the ":torrents" remote folder specification and without the ":" at the end of the destination? e.g.: "rclone mount RealDebrid: /volume1/docker/plex/media/rd-torrents/ --config=/volume1/rclone.conf --cache-dir=/volume1/docker/plex/cache --vfs-cache-mode full --allow-other --dir-cache-time 10s"

If that still doesnt work, make sure there is no mount running in that directory at the moment by running the command "fusermount -u /volume1/docker/plex/media/rd-torrents/"

Perhaps also check that all rclone processes are closed by running "top"

Was typing this as you mentioned!

@itsToggle
Copy link
Owner

awesome! Let me know if you encounter any other issues :)

@richardgetz
Copy link
Author

Separately, anything specific you need done on the plex_debrid side? I am a python dev and happy to jump in and submit a PR if you have something in mind.

@itsToggle
Copy link
Owner

oh come to think of it, Im really struggling with a few things.. some rather simple and some more complex:

  • I have no idea how to create a "requirements.txt", so that people dont need to run "pip install" for every missing module. Its pretty embarrassing, but Ive spent literal hours trying to find out what to put in that stupid txt file and nothing seems to work haha
  • Im also more generally struggeling to write things in a way so that people can easily contribute. The script keeps getting more complex and even I struggle to remember where in the script Ive written a specific part. At the moment Im thinking of splitting this script appart into a few seperate python "modules", which would make contributing to a single part of the script easier for me and others. Is that the "pythonic" way? How would you go about this? :)

@richardgetz
Copy link
Author

richardgetz commented Aug 19, 2022

To create a requirements file you can run:
pip freeze > requirements.txt

It will create a requirements.txt file inside whichever directory you are in. If that doesn't work for some reason, it is likely an environment issue and I can help debug this separately.

I do think it is a good idea to split it up a bit so it is easier to follow/debug. First thing I would do is split up each class into its own file and import it into a main (or __init__.py to be more pythonic). Once that piece is done it is easier to edit the classes for readability to make edits on the fly. I can take a first stab at tidying without editing the functionality to start so you can review and we can discuss it from there, if that works for you?

@itsToggle
Copy link
Owner

Ill give the requirements.txt another shot :)

That would be awesome! Thank you so much! Im gonna warn you now though, i only have very basic python knowledge and the whole script is pretty messy.. If its not transparent enough right now, I could start cleaning it up a bit before you make the effort :)

@richardgetz
Copy link
Author

richardgetz commented Aug 19, 2022

I don't mind, I have very little Plex and RD knowledge so it sounds like we will need to lean on each other for different pieces. I took some time to walk through your code last night and I feel like I have a good understanding of it. I'll also add a requirements file while I'm at it. Going to try to get something together this weekend.

@itsToggle
Copy link
Owner

Nice! Thanks for investing the time. I'll close this original issue for now, but we can continue the discussion here until you create a pull request or something and we can move over there.

@itsToggle
Copy link
Owner

Okay so I'm currently trying to split the script into separate modules, but ive got some questions regarding the "import" chain. I now have a "main.py" script and several folders corresponding to the main components. Each folder and their subfolders contains a init.py file and some modules, as illustrated:

main.py
scraper:
  __init__.py
  services:
    __init__.py
    rarbg.py
    ...

I figured out a way to import them so that I can still call them with their "dotted" names (e.g. scraper.servies() and so on)

What I cant figure out is how I can make all these split-up files (modules) inherit modules like "requests" from the "main.py" script. I want to avoid having to import requests for every single module I've created. I couldn't find the right terms to google and I thought perhaps you know how to achieve this :)

@richardgetz
Copy link
Author

Normally you wouldn't want to inherit anything from main.py downward as you would get into a circular import, assuming main.py imports the services.

If you're doing the exact same call with requests then you could create a new file and put a function in there that you import as needed. However, there's no issue with importing requests multiple times across all files as it'll only be loaded into memory once.

I've been working on this as well but I was struggling with the file structure myself and decided to step backwards and focus on getting the main functionality working. So far I've pulled in several other resources like the python Plex api and a pre created torrent search api. I may have ended up changing so much that it would be rude to attempt to create a PR for this but when I have it presentable I'll share the repo with you and let you make that decision.

I've had quite a few shows that are unable to find all of the episodes that I've now found solutions for. I've also added highest quality and name scoring to determine when sites return the incorrect details.

@itsToggle
Copy link
Owner

Thanks for info! And great, I'd love to see it 👍 I'm curious on how you solved these issues :)

@richardgetz
Copy link
Author

Not done yet but here is what I have so far. https://github.com/richardgetz/PlexFund

I am now using Jackett to manage torrent searches so it is configurable without having to change the script or add support for other services. I am also adding a service to collect web videos in cases where a torrent cannot be found, or fails after trying available torrents. I am in the process of adding a json file to track what has been tried already and adding configurable timeouts.

@itsToggle
Copy link
Owner

Sounds awesome, I'll have a look! :)

I thought about adding filehoster scrapers aswell. Most German content for example is uploaded on filehosters like rapidgator and shared on forums like boerse.bz. I've written a few scrapers for sites like that already. The problem is, that most media shared this way is compressed into rar archives, which of course needs to be unpacked first.. I played around with rar2fs for a bit (a program that unpacks the archives while you stream the movie inside them), but could never get it to work properly with a realdebrid mount.

@richardgetz
Copy link
Author

richardgetz commented Sep 16, 2022

I ended up putting a pause on my script as I found a nearly perfect setup for how I want it. What I ended up doing was installing docker containers for Jackett, Sonarr, Radarr, and RealDebrid Client. When I watchlist a show in Plex it gets queued by Sonarr, which searches my Jackett indexes, and sends one for download to the RealDebrid Client. I have storage space available, so for me it doesn't matter but you could do the same and skip the download process using the rclone version you made if you didn't want to download the files. The same happens for movies with Radarr. The only two caveats, Plex watchlisting is fairly new on Radarr so I had to use the develop build, but that will pass, and I had to create a cron job to poll the Plex watchlist import more frequently as I wanted it to be nearly immediate. After standing everything up shows end up on RD as quickly as the cron runs, I have it set to a minute.

For anyone who stumbles upon this:
https://github.com/Jackett/Jackett
https://github.com/Sonarr/Sonarr
https://github.com/Radarr/Radarr
https://github.com/rogerfar/rdt-client

@berot3
Copy link

berot3 commented Mar 17, 2023

but could never get it to work properly with a realdebrid mount.

Sorry to comment on this after so long, but this sounds very interesting 😄 did you find anything to make it work with boerse?

@berot3
Copy link

berot3 commented Mar 17, 2023

Plex watchlisting is fairly new on Radarr so I had to use the develop build, but that will pass

I use overseer for the Plex watchlist for sonarr/radarr.

How is your setup going so far? I'd like to do the same. But I'm still hesitating since I don't have the storage. I would love this setup but with rclone like itstoggle is doing it.

When I put something on Plex watchlist, overseer adds it to sonarr/radarr and they make it available on real debrid. But I don't know how to do this through rclone instead of downloading. I want to directly stream it.

@itsToggle
Copy link
Owner

That's exactly what plex_debrid does :)

regarding a boerse integration, I've not invested any more time into getting it to work. I could make a repository public that shows the code I've written for scraping their site and bypassing captchas on link vaults like "keeplinks".
Making these multipart rar files streamable through rclone is technically possible with a rar2fs layer ontop of your rclone mount. There are a few problems with streaming these files and keeping them "alive" though, which is why this isn't implemented.

@berot3
Copy link

berot3 commented Mar 17, 2023

That's exactly what plex_debrid does :)

Thank you so much for this fantastic solution. I'm looking forward to test it asap.

So basically I need to ditch sonarr/radarr??! Doesn't sound right 😢😄
I was actually hoping/expecting to keep using sonarr/radarr and use debrid as a download client.
Im still new to this debrid-thing. 😄

Btw, since I wanted to ask this for couple days: how do you feel about debrid destroying the torrent-"environment"? Since many seeders are eliminated, it makes public torrents slower and die earlier. But how big is the effect really? And there are still private trackers to protect against debrid-leechers, I guess.

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

No branches or pull requests

3 participants