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

Custom directory path per source #441

Open
11notes opened this issue Nov 30, 2023 · 8 comments
Open

Custom directory path per source #441

11notes opened this issue Nov 30, 2023 · 8 comments

Comments

@11notes
Copy link

11notes commented Nov 30, 2023

First of all: Thank you for providing FOSS, you are a part of the people who make the world a better place by providing free solutions to niche problems, thank you.

Would it be possible to add a custom directory path for each source? /downloads/video/{NAME} is too static, it would be nice that we can use any directory path we like “/youtube/science/{NAME}”, “/news/videos/{NAME}” and so on? I know I can “ln -s /downloads/video” to any root directory I want, but it would be nice if this step is not needed. Maybe even allow the use of variables in the name like for the file name “/your/custom/path/{yyyy}/{source}”. Like this we can also place media on different servers via different mounts. Thanks!

@meeb
Copy link
Owner

meeb commented Nov 30, 2023

Thanks for the comments!

This has been discussed in a couple of over overlapping or duplicate issues, but in answer to your specific questions:

  • There will generally need to always be a "download root" such as /downloads - this is a security thing generally. It is possible to disable all security checks and enable this, but it generally wouldn't be a good option for most people so I doubt this would get removed. Given you mention /downloads I'm going to assume you're using the container.
  • The video/ and audio/ enforced directory names are to do with how tubesync was designed to be used, which is as a downloader to a media server like Plex or Jellyfin, the addtional directory is required otherwise you could mix video and audio downloads in the same library which isn't handled by media servers.
  • It has been discussed to allow some more custom sub-directory naming, so while /your/custom/path/anything isn't likely, something along the lines of /downloads/video/whatever/you/want/here is likely to be possible in the future. This requires quite a bit of work to get the handling of associated metadata files (JSON, NFO, thumbnails, etc.) to be rewritten.

While you can use symlinks, usually a cleaner way is to use container volume mounts for additional flexibility on mapping to the host.

@11notes
Copy link
Author

11notes commented Nov 30, 2023

Currently it informs me that I can’t use any directory outside of /downloads and that’s the underlying issue. Sure I can use mounts, symlinks and what not to redirect /downloads/video/{source} to any directory but if I specify a custom directory, or activate a checkbox (use custom directory) it would be nice to not have to use /downloads/video but directly /my/custom/path/{source}

@meeb
Copy link
Owner

meeb commented Nov 30, 2023

If you're downloading inside of a container why does the initial directory prefix matter?

@11notes
Copy link
Author

11notes commented Nov 30, 2023

Imagine you have three different storage endpoints. Now I have to mount all three of them as /downloads/video/A, /downloads/video/B and /downloads/video/C, on top of that I have to remember that when I add a source to add the full path /downloads/video/A/custom/directory/{source}. Would be cleaner if I can do /A/custom/directory/{source}

@meeb
Copy link
Owner

meeb commented Nov 30, 2023

Surely you would need to create three volume mounts, one for each storage endpoint /A /B and /C, anyway? The only difference is instead of /A/... /B/... and /C/... you would map to /downloads/video/A/... /downloads/video/B/... and /downloads/video/C/... as you say (once you can customise the directory paths bit more anyway) right?

You should be able to specify a directory like /downloads/video/A/custom/source/ in a future release, that's already on the wishlist.

I can't see me reworking the entire file storage system to accommodate completely arbitrary custom file system roots just to remove the /downloads/video/ prefix for a volume map. Not only would it be substantial work, I don't philosophically agree with it unless I've still misunderstood the issue.

@11notes
Copy link
Author

11notes commented Nov 30, 2023

/downloads/video/my/directory/{source}, works already, all I thought would make sense to allow anything outside of /downloads/video 😊, that’s only an if statement maybe even with a checkbox to only allow directories outside of /downloads/video for “experts”.


If custom_directory_enabled  then
	If custom_directory_exists then
		use custom directory

@meeb
Copy link
Owner

meeb commented Nov 30, 2023

I believe the custom directory paths are currently slightly broken (some metadata doesn't get downloaded to the right directory, automatic deletion doesn't work in some cases etc.). It's not an official feature I would suggest yet, but if it works for you that's great.

The logic is way more complicated than a tick box and involves a defined file system storage inside of the Django framework:

https://github.com/meeb/tubesync/blob/main/tubesync/sync/models.py#L26

docs: https://docs.djangoproject.com/en/4.2/ref/files/storage/

While you can change /downloads (defined in settings.DOWNLOAD_ROOT)to something else via settings.py this has to be defined to a directory. Setting this to just / might technically work, but would be an extremely bad idea (as all of the files in the container would then technically be in the Media items file system, security, overwriting and permission issues would be massive).

To support multiple file system storage areas it would be significant work, Django file fields don't support multiple storage systems and file storage systems don't support multiple locations so this would require a lot of bug prone, flaky internal hacking of Django to support. In short, it's extremely complicated and I'm certainly not going to add it.

@tcely
Copy link
Contributor

tcely commented Jan 11, 2025

I believe the custom directory paths are currently slightly broken (some metadata doesn't get downloaded to the right directory, automatic deletion doesn't work in some cases etc.).

I made an attempt at solving most of these problems. See: #599 #598 #586

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

No branches or pull requests

3 participants