-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFileBot Xattr Series Scanner.py
50 lines (37 loc) · 1.56 KB
/
FileBot Xattr Series Scanner.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
import re, Media, VideoFiles
from filebot import *
VideoFiles.ignore_dirs.remove('bdmv')
excl_dirs = ['backup', 'clipinf', 'playlist']
VideoFiles.ignore_dirs.extend(excl_dirs)
def Scan(path, files, mediaList, subdirs, language=None, root=None):
VideoFiles.Scan(path, files, mediaList, subdirs, root)
for file in files:
attr = xattr_metadata(file)
if attr is None:
continue
print("[XATTR] %s" % attr)
# single episode | multi episode
episodes = list_episodes(attr)
multi_episode_count = len(episodes)
for i, attr in enumerate(episodes):
guid = series_guid(attr)
name = series_name(attr)
special = episode_special_number(attr)
media = Media.Episode(
name.encode('utf-8'), # use str since Plex doesn't like unicode strings
0 if special else episode_season_number(attr),
special if special else episode_number(attr),
episode_title(attr).encode('utf-8'), # use str since Plex doesn't like unicode strings
series_year(attr)
)
date = episode_date(attr)
if date:
media.released_at = date.strftime('%Y-%m-%d')
if (multi_episode_count > 1):
media.display_offset = (i * 100) / multi_episode_count
original_filename = xattr_filename(file)
if original_filename:
media.source = VideoFiles.RetrieveSource(original_filename.encode('utf-8'))
media.parts.append(file)
mediaList.append(media)
print("[MEDIA] %s | %s | %s | %s" % (media, media.year, media.released_at, media.source))