-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_renamed_vids.py
executable file
·54 lines (52 loc) · 1.54 KB
/
list_renamed_vids.py
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
#!/usr/bin/env python3
#
# import modules
#
import os
import sys
import configparser
from pprint import pprint
from plexapi.server import PlexServer
#
# set default variables
#
config = configparser.ConfigParser()
config.read(os.getenv('HOME')+'/.plexconfig.ini')
plexHost = config['default']['plexHost']
plexPort = config['default']['plexPort']
plexSection = config['default']['plexSection']
plexToken = config['default']['plexToken']
plexSectionName = config['default']['plexSectionName']
baseurl = f"http://{plexHost}:{plexPort}"
#
# Connect to server
#
plex = PlexServer(baseurl, plexToken)
#
# Select section
#
plexSection = plex.library.section(plexSectionName)
for video in plexSection.all():
matchFound = False
# if len(video.locations) > 1:
# print(f"{video.title} has multiple locations!")
# for location in video.locations:
# print(location)
# print('')
# else:
for location in video.locations:
if video.title in location:
matchFound = True
if " PPV " in video.locations[0]:
# Leave these alone for rsync purposes
matchFound = True
elif '?' in video.title:
# Can't use this in a filename
matchFound = True
if matchFound is False:
oldLocation = video.locations[0].replace('/data/NSFW Scenes/', '')
newFname = f"{video.title}.mp4"
writerNames = newFname.split(' - ', 1)[0]
writersList = writerNames.split(',')
firstWriter = writersList[0]
print(f"mv \"{oldLocation}\" \"{firstWriter}/{newFname}\"")