-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean-collections.py
More file actions
29 lines (21 loc) · 983 Bytes
/
Copy pathclean-collections.py
File metadata and controls
29 lines (21 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
'''
Collections is cool but Plex auto-creates them, even when where is only one movie in a collection.
You can turn this off, but when you have to create *all* collections by hand.. I figured I'd leave it on and then
just prune the extra collections once in a while.. at least that was the thought for this script (picked up most of
it from a Reddit thread).
'''
import getpass
from plexapi.myplex import MyPlexAccount
username = input("Plex Username: ")
server = input("Plex Server: ")
password = getpass.getpass()
account = MyPlexAccount(username, password)
plex = account.resource(server).connect()
movies = plex.library.section('Movies')
collections = {c.title: c.fetchItems(c.fastKey) for c in movies.listChoices('collection')}
for collection, movies in collections.items():
if len(movies) < 3:
for movie in movies:
movie.removeCollection(collection)
print('Removed {} from {}'.format(movie.title, collection))