[GH-ISSUE #10] On 1st run: TimeoutError and on 2nd run: FileExistsError #8

Closed
opened 2026-03-23 20:32:48 +00:00 by mirror · 11 comments
Owner

Originally created by @cryodream on GitHub (Aug 16, 2023).
Original GitHub issue: https://github.com/tubearchivist/tubearchivist-jf/issues/10

I tried testing out this TA and Jellyfin integration. I am running docker containers on unraid.
A brand new TubeArchivist v0.4.0 with only 3 videos.
A dedicated Jellyfin 10.8.10 (from hotio).

On the first run I get timeout error on creating a season folder, even though it actually gets created:

# docker exec -it tube-archivist-jf python main.py
[connection] verified jellyfin connection
[connection] verified tube archivist connection
waiting for library refresh
[show][UClFSU9 bUb4Rc6OYfTt5SPw] indexing 1 videos
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
[setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created
Traceback (most recent call last):
  File "/app/main.py", line 18, in <module>
    main()
  File "/app/main.py", line 14, in main
    library.validate_series()
  File "/app/src/series.py", line 39, in validate_series
    folders: list[str] | None = show_handler.validate_episodes()
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/series.py", line 161, in validate_episodes
    season_folder: str | None = self.create_season(ta_video, jf_ep)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/series.py", line 192, in create_season
    self._wait_for_season(expected_season)
  File "/app/src/series.py", line 210, in _wait_for_season
    raise TimeoutError("timeout reached for creating season folder")
TimeoutError: timeout reached for creating season folder

On the second run I get file exists error, when it finds that previously created folder:

# docker exec -it tube-archivist-jf python main.py
[connection] verified jellyfin connection
[connection] verified tube archivist connection
[show][Philip DeFranco] indexing 1 videos
Traceback (most recent call last):
  File "/app/main.py", line 18, in <module>
    main()
  File "/app/main.py", line 14, in main
    library.validate_series()
  File "/app/src/series.py", line 39, in validate_series
    folders: list[str] | None = show_handler.validate_episodes()
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/series.py", line 161, in validate_episodes
    season_folder: str | None = self.create_season(ta_video, jf_ep)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/series.py", line 191, in create_season
    os.makedirs(season_folder)
  File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists: '/youtube/UClFSU9_bUb4Rc6OYfTt5SPw/2023'

Files before running the script:
2023-08-16_10-01-31__WindowsTerminal

And after:
2023-08-16_10-01-50__WindowsTerminal

Huh... 🤪 Is this a file permissions problem, something else, or a bug?

Originally created by @cryodream on GitHub (Aug 16, 2023). Original GitHub issue: https://github.com/tubearchivist/tubearchivist-jf/issues/10 I tried testing out this TA and Jellyfin integration. I am running docker containers on unraid. A brand new TubeArchivist v0.4.0 with only 3 videos. A dedicated Jellyfin 10.8.10 (from hotio). On the first run I get timeout error on creating a season folder, even though it actually gets created: ```bash # docker exec -it tube-archivist-jf python main.py [connection] verified jellyfin connection [connection] verified tube archivist connection waiting for library refresh [show][UClFSU9 bUb4Rc6OYfTt5SPw] indexing 1 videos [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created [setup][f08dec29ae70d11cef802dad09518fcc] waiting for seasons to be created Traceback (most recent call last): File "/app/main.py", line 18, in <module> main() File "/app/main.py", line 14, in main library.validate_series() File "/app/src/series.py", line 39, in validate_series folders: list[str] | None = show_handler.validate_episodes() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/src/series.py", line 161, in validate_episodes season_folder: str | None = self.create_season(ta_video, jf_ep) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/src/series.py", line 192, in create_season self._wait_for_season(expected_season) File "/app/src/series.py", line 210, in _wait_for_season raise TimeoutError("timeout reached for creating season folder") TimeoutError: timeout reached for creating season folder ``` On the second run I get file exists error, when it finds that previously created folder: ```bash # docker exec -it tube-archivist-jf python main.py [connection] verified jellyfin connection [connection] verified tube archivist connection [show][Philip DeFranco] indexing 1 videos Traceback (most recent call last): File "/app/main.py", line 18, in <module> main() File "/app/main.py", line 14, in main library.validate_series() File "/app/src/series.py", line 39, in validate_series folders: list[str] | None = show_handler.validate_episodes() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/src/series.py", line 161, in validate_episodes season_folder: str | None = self.create_season(ta_video, jf_ep) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/src/series.py", line 191, in create_season os.makedirs(season_folder) File "<frozen os>", line 225, in makedirs FileExistsError: [Errno 17] File exists: '/youtube/UClFSU9_bUb4Rc6OYfTt5SPw/2023' ``` Files before running the script: ![2023-08-16_10-01-31__WindowsTerminal](https://github.com/tubearchivist/tubearchivist-jf/assets/844036/f415fcd9-c76f-4d67-8e6c-065c6915b641) And after: ![2023-08-16_10-01-50__WindowsTerminal](https://github.com/tubearchivist/tubearchivist-jf/assets/844036/cbff9880-bf72-4cd8-a7ea-1c64c1a4bb6d) Huh... 🤪 Is this a file permissions problem, something else, or a bug?
mirror 2026-03-23 20:32:48 +00:00
Author
Owner

@bbilly1 commented on GitHub (Aug 16, 2023):

I've added a short limitations section to the readme here:
https://github.com/tubearchivist/tubearchivist-jf#limitations

But ultimately as the error message says, JF doesn't pickup the temporary season folder created and the extension will eventually give up.

<!-- gh-comment-id:1680770662 --> @bbilly1 commented on GitHub (Aug 16, 2023): I've added a short *limitations* section to the readme here: https://github.com/tubearchivist/tubearchivist-jf#limitations But ultimately as the error message says, JF doesn't pickup the temporary season folder created and the extension will eventually give up.
Author
Owner

@cryodream commented on GitHub (Aug 16, 2023):

So does this mean, that tubearchivist-jf creates the season folder as root and then jellyfin does not see it? Or am I misunderstanding something?
If yes, how can I force tubearchivist-jf to use nobody:users?
Or do I have to run jellyfin as root?

<!-- gh-comment-id:1680888151 --> @cryodream commented on GitHub (Aug 16, 2023): So does this mean, that `tubearchivist-jf` creates the season folder as `root` and then `jellyfin` does not see it? Or am I misunderstanding something? If yes, how can I force `tubearchivist-jf` to use `nobody:users`? Or do I have to run `jellyfin` as `root`?
Author
Owner

@bbilly1 commented on GitHub (Aug 16, 2023):

this is only tested as in the example compose file on regular Ubuntu server. there it doesn't need any permission changes.

not sure about unraid though.

please help with making this compatible by making a PR.

<!-- gh-comment-id:1680923725 --> @bbilly1 commented on GitHub (Aug 16, 2023): this is only tested as in the example compose file on regular Ubuntu server. there it doesn't need any permission changes. not sure about unraid though. please help with making this compatible by making a PR.
Author
Owner

@cryodream commented on GitHub (Aug 16, 2023):

As a temporary solution, I've managed to make it work by running a separate jellyfin container as root.

Just FYI, delete/remove the PUID and PGID env variables from your jellyfin's docker-compose.yaml or in my case - jellyfin's CA template (unraid).

@bbilly1 sorry, I've got too little experience with both python and docker to be able to make a PR.

<!-- gh-comment-id:1681085801 --> @cryodream commented on GitHub (Aug 16, 2023): As a temporary solution, I've managed to make it work by running a separate jellyfin container as `root`. Just FYI, delete/remove the `PUID` and `PGID` env variables from your jellyfin's `docker-compose.yaml` or in my case - jellyfin's CA template (unraid). @bbilly1 sorry, I've got too little experience with both python and docker to be able to make a PR.
Author
Owner

@bbilly1 commented on GitHub (Aug 17, 2023):

would chmod 777 work on that temporary season folder 2023? would that allow JF to find the folder?

<!-- gh-comment-id:1681463286 --> @bbilly1 commented on GitHub (Aug 17, 2023): would chmod 777 work on that temporary season folder 2023? would that allow JF to find the folder?
Author
Owner

@birdwing commented on GitHub (Aug 30, 2023):

would chmod 777 work on that temporary season folder 2023? would that allow JF to find the folder?

I believe so. I had a similar issue.

I have Tubearchivist running in a docker container, with the /youtube folder being mounted to the local filesystem, rather than a docker Volume.

After I setup Tubearchivist I finally got around to setting up portainer. So Tubearchivist-jf and Jellyfin are running inside of Portainer, and Tubearchivist is running outside of portainer. I ended up creating a NFS share of the /youtube folder so that portainer could access it (through a NFS volume inside portainer).

I had permission issues until I ran a recursive chmod command on the /youtube folder:

chmod 777 youtube -R

I then ran into the issue that I was using the HOST_UID and HOST_GID environment variables for tubearchivist, so the chmod was short lived. I removed the HOST_UID and HOST_GID so that Tubearchivist was using the container user. Re-ran the chmod command, and all has worked well.

So I believe that chmod 777 would work. I ran it recursively on the entire /youtube directory, and have had no issues since.

I think as long as tubearchivist isn't configured to use a host user (HOST_UID and HOST_GID) and the /youtube folder is mounted instead of used as a volume, then chmod works.

<!-- gh-comment-id:1699606164 --> @birdwing commented on GitHub (Aug 30, 2023): > would chmod 777 work on that temporary season folder 2023? would that allow JF to find the folder? I believe so. I had a similar issue. I have Tubearchivist running in a docker container, with the /youtube folder being mounted to the local filesystem, rather than a docker Volume. After I setup Tubearchivist I finally got around to setting up portainer. So Tubearchivist-jf and Jellyfin are running inside of Portainer, and Tubearchivist is running _outside_ of portainer. I ended up creating a NFS share of the /youtube folder so that portainer could access it (through a NFS volume inside portainer). I had permission issues until I ran a recursive chmod command on the /youtube folder: ``` chmod 777 youtube -R ``` I then ran into the issue that I was using the HOST_UID and HOST_GID environment variables for tubearchivist, so the chmod was short lived. I removed the HOST_UID and HOST_GID so that Tubearchivist was using the container user. Re-ran the chmod command, and all has worked well. So I believe that chmod 777 would work. I ran it recursively on the entire /youtube directory, and have had no issues since. I think as long as tubearchivist isn't configured to use a host user (HOST_UID and HOST_GID) and the /youtube folder is mounted instead of used as a volume, then chmod works.
Author
Owner

@birdwing commented on GitHub (Aug 30, 2023):

I take back everything I just said.....

I just had a permissions issue. Seems like TA marks all videos as Owned by the container user, or the specified Host user (even if HOST_UID and HOST_GID are blank) this breaks the permissions and prevents the files from being modified by the tubearchivist-jf container.

It seems like the issue is the permissions that Tubearchivist itself assigns the files that are downloaded.
I am getting permission issues on Tubearchivist-jf, not jellyfin.

Jellyfin can see the files, however Tubearchivist-jf does not have permission to create the temporary season folders inside of the /youtube folder managed by Tubearchivist itself.

Is there a way to have Tubearchivist create it's folders and files with more open permissions?

<!-- gh-comment-id:1699619767 --> @birdwing commented on GitHub (Aug 30, 2023): I take back everything I just said..... I just had a permissions issue. Seems like TA marks all videos as Owned by the container user, or the specified Host user (even if HOST_UID and HOST_GID are blank) this breaks the permissions and prevents the files from being modified by the tubearchivist-jf container. It seems like the issue is the permissions that Tubearchivist itself assigns the files that are downloaded. I am getting permission issues on Tubearchivist-jf, not jellyfin. Jellyfin can see the files, however Tubearchivist-jf does not have permission to create the temporary season folders inside of the /youtube folder managed by Tubearchivist itself. Is there a way to have Tubearchivist create it's folders and files with more open permissions?
Author
Owner

@birdwing commented on GitHub (Aug 30, 2023):

Just confirmed.

I have HOST_UID and HOST_GID disabled. I set the /youtube to be owned by nobody, and chmod 777.
Tubearchivist downloaded a new video for a new channel:

image

And that new directory (3rd from top) was created as owned by root without full permissions.
Running python main.py on Tubearchivist-jf gives me this error:

Traceback (most recent call last):
  File "/app/main.py", line 18, in <module>
    main()
  File "/app/main.py", line 14, in main
    library.validate_series()
  File "/app/src/series.py", line 39, in validate_series
    folders: list[str] | None = show_handler.validate_episodes()
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/series.py", line 163, in validate_episodes
    season_folder: str | None = self.create_season(ta_video, jf_ep)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/series.py", line 195, in create_season
    os.makedirs(season_folder)
  File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/youtube/UCnmGIkw-KdI0W5siakKPKog/2023'

So the issue is Tubearchivist-jf can't create the necessary directories for Jellyfin to read because the permissions that TA puts in by default are too strict.
Those permissions only work if all the docker containers are running on the same host, this means that it is currently impossible to mount the TA directory to a NFS, or any other external source (or in my case my own stupidity of having some docker containers inside portainer and others outside portainer)

<!-- gh-comment-id:1699649193 --> @birdwing commented on GitHub (Aug 30, 2023): Just confirmed. I have HOST_UID and HOST_GID disabled. I set the /youtube to be owned by nobody, and chmod 777. Tubearchivist downloaded a new video for a new channel: ![image](https://github.com/tubearchivist/tubearchivist-jf/assets/6484397/826accd6-ed9b-439c-91bc-d04d5954ffba) And that new directory (3rd from top) was created as owned by root without full permissions. Running ```python main.py``` on Tubearchivist-jf gives me this error: ``` Traceback (most recent call last): File "/app/main.py", line 18, in <module> main() File "/app/main.py", line 14, in main library.validate_series() File "/app/src/series.py", line 39, in validate_series folders: list[str] | None = show_handler.validate_episodes() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/src/series.py", line 163, in validate_episodes season_folder: str | None = self.create_season(ta_video, jf_ep) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/src/series.py", line 195, in create_season os.makedirs(season_folder) File "<frozen os>", line 225, in makedirs PermissionError: [Errno 13] Permission denied: '/youtube/UCnmGIkw-KdI0W5siakKPKog/2023' ``` So the issue is Tubearchivist-jf can't create the necessary directories for Jellyfin to read because the permissions that TA puts in by default are too strict. Those permissions only work if all the docker containers are running on the same host, this means that it is currently impossible to mount the TA directory to a NFS, or any other external source (or in my case my own stupidity of having some docker containers inside portainer and others outside portainer)
Author
Owner

@birdwing commented on GitHub (Aug 30, 2023):

I should just finish my testing before posting, but I did get the NFS to work.

In the /etc/exports file for NFS you have to set the "no_root_squash" option for the NFS share

/root/tubearchivist/youtube 10.0.0.xxx(rw,sync,no_subtree_check,no_root_squash)

The no_root_squash option is what allows the tubearchivist-jf "root user" to access the files created by the tubearchivist "root user" across an NFS.

So I have found that in my case:

  • Mounting the /youtube folder instead of using a volume
  • Configuring tubearchivist without the (HOST_UID and HOST_GID) options so that files and folders are owned by "root"
  • Setting that folder as an NFS share with the "no_root_squash" option

Allows both Jellyfin and tubearchivist-jf to properly access the folders and files.

<!-- gh-comment-id:1699689914 --> @birdwing commented on GitHub (Aug 30, 2023): I should just finish my testing before posting, but I did get the NFS to work. In the /etc/exports file for NFS you have to set the "no_root_squash" option for the NFS share ``` /root/tubearchivist/youtube 10.0.0.xxx(rw,sync,no_subtree_check,no_root_squash) ``` The no_root_squash option is what allows the tubearchivist-jf "root user" to access the files created by the tubearchivist "root user" across an NFS. So I have found that in my case: - Mounting the /youtube folder instead of using a volume - Configuring tubearchivist without the (HOST_UID and HOST_GID) options so that files and folders are owned by "root" - Setting that folder as an NFS share with the "no_root_squash" option Allows both Jellyfin and tubearchivist-jf to properly access the folders and files.
Author
Owner

@numkem commented on GitHub (Oct 3, 2023):

I've opened a PR that fixes the FileExistsError and addresses another issue I found when trying to find a season.

<!-- gh-comment-id:1745842863 --> @numkem commented on GitHub (Oct 3, 2023): I've opened a PR that fixes the `FileExistsError` and addresses another issue I found when trying to find a season.
Author
Owner

@bbilly1 commented on GitHub (Oct 18, 2023):

new release v0.1.2 handles the FileExistsError. Additionally temporary folders are created with umask 777 now, solving permission problems, at least in some cases.

If you need more control under what user this runs, you might want to use the standalone installation instead.

<!-- gh-comment-id:1767569625 --> @bbilly1 commented on GitHub (Oct 18, 2023): new release v0.1.2 handles the FileExistsError. Additionally temporary folders are created with umask 777 now, solving permission problems, at least in some cases. If you need more control under what user this runs, you might want to use the standalone installation instead.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tubearchivist/tubearchivist-jf#8
No description provided.