blacktwin / JBOPS

Just a Bunch Of Plex Scripts
1.71k stars 304 forks source link

If server has values with emoji symbols the script can't use these values #228

Closed Lockszmith-GH closed 4 years ago

Lockszmith-GH commented 4 years ago

I'll start by: awesome script, I discovered it recently, and this one will become a critical part of my home-media-server toolbox. Thanks for making it.

Describe the bug I have a few library named with emojis, I found that when the client supports it, the visuals make it really clear what they are.

The problem is that the script doesn't handle them well:

Link to script with bug/issue https://github.com/blacktwin/JBOPS/blob/master/utility/plex_api_share.py

To Reproduce Steps to reproduce the behavior:

  1. Name a library with one of the following symbols "Name with 🏛♣"
  2. try to use the library as a --libraries parameter: ./plex_api_share.py --user "<username>" --add --share --libraries "Name with 🏛♣"

Expected behavior Library should be recognized, and action should not fail.

Output

Given the following output from --help:

❯ ./plex_api_share.py --help
<....> # removed for clarity
  --libraries  [ ...]   Space separated list of case sensitive names to process. Allowed names are: 
                        (choices: .Movies 🏛♣, .TV Shows 🏛♣, <....>,'1.TV', '1.TV.Expire ⏳', <....>
  --allLibraries        Select all libraries.
<....>

This is what I run:

❯ ./plex_api_share.py --user "zTester" --add --share --libraries '.Movies 🏛♣'                                                                            
Traceback (most recent call last):                                                                                                                       
  File "./plex_api_share.py", line 417, in <module>                                                                                                      
    share(user, libraries, sync, camera, channels, filterMovies, filterTelevision,                                                                       
  File "./plex_api_share.py", line 224, in share                                                                                                         
    plex.myPlexAccount().updateFriend(user=user, server=plex, sections=sections, allowSync=allowSync,                                                    
  File "/usr/lib/python3.8/site-packages/plexapi/myplex.py", line 413, in updateFriend                                                                   
    sectionIds = self._getSectionIds(machineId, sections)                                                                                                
  File "/usr/lib/python3.8/site-packages/plexapi/myplex.py", line 498, in _getSectionIds                                                                 
    sectionIds.append(allSectionIds[sectionKey.lower()])                                                                                                 
KeyError: '.movies 🏛♣'

This also fails for --allLibraries:

❯ ./plex_api_share.py --user "zTester" --add --share --allLibraries
Traceback (most recent call last):
  File "./plex_api_share.py", line 417, in <module>
    share(user, libraries, sync, camera, channels, filterMovies, filterTelevision,
  File "./plex_api_share.py", line 224, in share
    plex.myPlexAccount().updateFriend(user=user, server=plex, sections=sections, allowSync=allowSync,
  File "/usr/lib/python3.8/site-packages/plexapi/myplex.py", line 413, in updateFriend
    sectionIds = self._getSectionIds(machineId, sections)
  File "/usr/lib/python3.8/site-packages/plexapi/myplex.py", line 498, in _getSectionIds
    sectionIds.append(allSectionIds[sectionKey.lower()])
KeyError: '.movies 🏛♣'            

System:

Additional context FYI, the '1.TV.Expire ⏳' name was successfully recognized.

❯ ./plex_api_share.py --user "zTester" --add --share --libraries "1.TV.Expire ⏳"                                                                        
zTester's updated shared libraries:                                                                                                                      
['1.TV.Expire ⏳']                                                                                                                                       
zTester's updated shared libraries:                                                                                                                      
[<....>, '1.TV.Expire ⏳', <....>]

Again, I want to say - awesome script. I'll probably end up renaming my libraries, use the script, then rename them back - that would be ok for now. Thanks for creating this automation.

blacktwin commented 4 years ago

Well, I've confirmed the issue... Can you go into the Users & Sharing and see if that emoji shows up? Here is my homepage with the emojis. Homepage displays the 🏛♣ but not the Users & Sharing area.

After removing 🏛 from the library name the ♣ now displays in the Users & Sharing area and can be used with the script. 🏛seems to be an illegal emoji.