l3uddz / plex_dupefinder

Find and delete duplicate files in Plex
GNU General Public License v3.0
303 stars 54 forks source link

Fail gracefully on unsupported library type #35

Closed mikenye closed 4 years ago

mikenye commented 4 years ago

In the event that a library type is not 'show' or 'movie', fail gracefully instead of causing an exception.

Before:

       _                 _                   __ _           _
 _ __ | | _____  __   __| |_   _ _ __   ___ / _(_)_ __   __| | ___ _ __
| '_ \| |/ _ \ \/ /  / _` | | | | '_ \ / _ \ |_| | '_ \ / _` |/ _ \ '__|
| |_) | |  __/>  <  | (_| | |_| | |_) |  __/  _| | | | | (_| |  __/ |
| .__/|_|\___/_/\_\  \__,_|\__,_| .__/ \___|_| |_|_| |_|\__,_|\___|_|
|_|                             |_|

#########################################################################
# Author:   l3uddz                                                      #
# URL:      https://github.com/l3uddz/plex_dupefinder                   #
# --                                                                    #
#         Part of the Cloudbox project: https://cloudbox.works          #
#########################################################################
#                   GNU General Public License v3.0                     #
#########################################################################

Initialized
Finding dupes...
Found 0 dupes for section 'Movies'
Found 2 dupes for section 'TV'
Traceback (most recent call last):
  File "/usr/local/bin/plex_dupefinder", line 354, in <module>
    dupes = get_dupes(section)
  File "/usr/local/bin/plex_dupefinder", line 52, in get_dupes
    dupe_search_results = plex.library.section(plex_section_name).search(duplicate=True, libtype=sec_type)
  File "/usr/lib/python3.8/site-packages/plexapi/library.py", line 504, in search
    args[category] = self._cleanSearchFilter(category, value, libtype)
  File "/usr/lib/python3.8/site-packages/plexapi/library.py", line 528, in _cleanSearchFilter
    raise BadRequest('Unknown filter category: %s' % category)
plexapi.exceptions.BadRequest: Unknown filter category: duplicate

After:

       _                 _                   __ _           _
 _ __ | | _____  __   __| |_   _ _ __   ___ / _(_)_ __   __| | ___ _ __
| '_ \| |/ _ \ \/ /  / _` | | | | '_ \ / _ \ |_| | '_ \ / _` |/ _ \ '__|
| |_) | |  __/>  <  | (_| | |_| | |_) |  __/  _| | | | | (_| |  __/ |
| .__/|_|\___/_/\_\  \__,_|\__,_| .__/ \___|_| |_|_| |_|\__,_|\___|_|
|_|                             |_|

#########################################################################
# Author:   l3uddz                                                      #
# URL:      https://github.com/l3uddz/plex_dupefinder                   #
# --                                                                    #
#         Part of the Cloudbox project: https://cloudbox.works          #
#########################################################################
#                   GNU General Public License v3.0                     #
#########################################################################

Initialized
Finding dupes...
Found 0 dupes for section 'Movies'
Found 3 dupes for section 'TV'
Section 'Music' of type 'artist' is not supported
Found 0 dupes for section 'Music'

...
mikenye commented 4 years ago

Sorry, didn't read contributing.md. Now realise I needed to push to develop branch. I'll re-submit this.