Casvt / Plex-scripts

Plex, the arr's and tautulli scripts coming from user requests
GNU General Public License v3.0
338 stars 30 forks source link

audio_sub_changer.py: Quotations and spaces for --LibraryName giving errors. Calling --User @me gives error #180

Closed RileyXX closed 11 months ago

RileyXX commented 1 year ago

In which file is the bug?

audio_sub_changer.py

Short overview:

I was playing around with this script today trying to set it up and ran into a few errors.

1. Error when --LibraryName contains spaces:

AudioSubChanger.py --Type subtitle --Language en --LibraryName 'TV Shows' --LibraryName 'Movies' --Forced avoid --Codec srt --Codec pgs --Codec ass --User @me gives the following error: AudioSubChanger.py: error: unrecognized arguments: Shows'

2. Error when --LibraryName contains quotations ' ':

AudioSubChanger.py --Type subtitle --Language en --LibraryName 'Movies' --Forced avoid --Codec srt --Codec pgs --Codec ass gives the following error: AudioSubChanger.py: error: Library not found

3. Error when calling --User @me

AudioSubChanger.py --Type subtitle --Language en --LibraryName Movies --Forced avoid --Codec srt --Codec pgs --Codec ass --User @me gives the following error:

line 166, in audio_sub_changer
    for username in user_data.keys():
RuntimeError: dictionary changed size during iteration

Conclusion

I was only able to get the script to run without --User and only on my Movies library using the following: AudioSubChanger.py --Type subtitle --Language en --LibraryName Movies --Forced avoid --Codec srt --Codec pgs --Codec ass

Casvt commented 1 year ago

First error: not a bug but just the shell being picky. Use double quotes. --LibraryName "TV Shows"

Second error: once again use double quotes. If the name contains double quotes, escape them. --LibraryName "John \"Johnny\" Smith's Movies"

Third error: this is an actual bug. I'll check it out and let you know :)

Casvt commented 1 year ago

I've updated the script. Please download it from here and try again. Let me know if this version works.

RileyXX commented 1 year ago

Ah I see thanks. I think I did try it with double quotes but I must have still had --User @me and just assumed it didn't work haha. Thanks for the quick response. This script is awesome. Will be adding it to my collection. You are very talented. Keep up the good work!

Error 1 & 2 confirmed working now with: AudioSubChanger.py --Type subtitle --Language en --LibraryName "TV Shows" --LibraryName "Movies" --Forced avoid --Codec srt --Codec pgs --Codec ass

Another question I have. Is it possible to use --LibraryName twice?

I tried running: AudioSubChanger.py --Type subtitle --Language en --LibraryName "TV Shows" --LibraryName "Movies" --Forced avoid --Codec srt --Codec pgs --Codec ass and it only ran on the "Movies" library.

Then I tried running with just "TV Shows" by itself: AudioSubChanger.py --Type subtitle --Language en --LibraryName "TV Shows" --Forced avoid --Codec srt --Codec pgs --Codec ass and it then it ran through the TV shows.

I made a .bat file with the following and it works great.

AudioSubChanger.py --Type subtitle --Language en --LibraryName "TV Shows" --Forced avoid --Codec srt --Codec pgs --Codec ass
AudioSubChanger.py --Type subtitle --Language en --LibraryName "Movies" --Forced avoid --Codec srt --Codec pgs --Codec ass
RileyXX commented 1 year ago

I've updated the script. Please download it from here and try again. Let me know if this version works.

Error 3 confirmed working now with --User @me. Nice job! Everything working now. Thank you!

Last question: Is it possible to use --LibraryName twice on one line?

I tried running: AudioSubChanger.py --Type subtitle --Language en --LibraryName "TV Shows" --LibraryName "Movies" --Forced avoid --Codec srt --Codec pgs --Codec ass and it only ran on the "Movies" library.

Then I tried running with just "TV Shows" by itself: AudioSubChanger.py --Type subtitle --Language en --LibraryName "TV Shows" --Forced avoid --Codec srt --Codec pgs --Codec ass and it then it ran through the TV shows.

Casvt commented 1 year ago

Last question: Is it possible to use --LibraryName twice on one line?

I'll add support for it no problem.

Other scripts that use the same target selection system also have the flags --AllMovies and --AllShows. Those target all libraries of their respective type in one go. I'll add support for those too because why not.

RileyXX commented 1 year ago

I'll add support for it no problem.

Other scripts that use the same target selection system also have the flags --AllMovies and --AllShows. Those target all libraries of their respective type in one go. I'll add support for those too because why not.

Damn nice that's a cool idea. That would definitely be useful. Thanks again. Cheers