-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
executable file
·73 lines (53 loc) · 2.26 KB
/
cli.py
File metadata and controls
executable file
·73 lines (53 loc) · 2.26 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python3
from pick import Picker
from plexapi.myplex import MyPlexAccount
import getpass
import re
import enum
import requests
import urllib
from plexsync.plexsync import PlexSync
from plexsync.base import getSettings
def _selectAll(picker):
print("selecting all")
return None
def chooseMedia(media: set):
_title = 'Please select the media you want to sync (press SPACE to select, ENTER to continue):'
#convert our media set to a list so we can match the selected indexes to the media
media_list = sorted(media, key=lambda m: m.title)
_options = [m.title for m in media_list]
picker = Picker(_options, _title, multi_select=True)
selected_items = picker.start()
wantedMedia = []
for s in selected_items:
media_index = s[1]
wantedMedia.append(media_list[media_index])
return wantedMedia
settings = getSettings()
plexsync = PlexSync()
username = input("MyPlex username:") or settings.get('auth', 'myplex_username')
password = getpass.getpass("MyPlex password:") or settings.get('auth', 'myplex_password')
if username and password:
account = plexsync.getAccount(username, password)
else:
print("Set a username and passsword in the config file")
exit(1)
tv_quality_profile = input("TV Quality Profile:") or settings.get('sonarr', 'quality_profile')
movie_quality_profile = input("Movie Quality Profile:") or settings.get('radarr', 'quality_profile')
plexsync.getServers(account)
your_server_name = input("Your server: ") or settings.get('servers', 'yours')
their_server_name = input("Their server: ") or settings.get('servers', 'theirs')
# returns a PlexServer instance
your_server = account.resource(your_server_name).connect()
# returns a PlexServer instance
their_server = account.resource(their_server_name).connect()
sections = settings.get('sections', 'sections').split(",")
for section in sections:
theirLibrary = plexsync.getResults(their_server, section)
yourLibrary = plexsync.getResults(your_server, section)
their_new_media = plexsync.compareLibrariesAsResults(yourLibrary, theirLibrary)
# plexsync.printMedia(their_new_media, section)
wantedMedia = chooseMedia(their_new_media)
for m in wantedMedia:
plexsync.download(m)
# plexsync.sendMediaToThirdParty(wantedMedia)