Skip to content

Commit

Permalink
Chore: minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu committed Dec 13, 2023
1 parent 3870dc0 commit 91eecd9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
27 changes: 18 additions & 9 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,24 @@ def update(self, metadata, media, lang, force=False):
# only generate chapters for media with single file
durations = [int(p.duration) for p in utils.extra_media_parts(media)
if int(p.duration) > 0]
if Prefs[KEY_ENABLE_CHAPTERS] and len(durations) == 1 \
and durations[0] > chapter_min_duration:
duration = durations[0]
for i, offset in enumerate(range(0, duration, chapter_gen_interval)):
start, end = offset, offset + chapter_gen_interval
chapter = metadata.chapters.new()
chapter.title = 'Chapter {i}'.format(i=(i + 1))
chapter.start_time_offset = start
chapter.end_time_offset = end if end < duration else duration
if Prefs[KEY_ENABLE_CHAPTERS]:
if not durations:
Log.Warn('Chapter: no valid duration for media: {id}'
.format(id=metadata.id))
elif len(durations) > 1:
Log.Warn('Chapter: ignore multi-part media: {id}'
.format(id=metadata.id))
elif durations[0] < chapter_min_duration:
Log.Warn('Chapter: ignore short-duration media: {id}'
.format(id=metadata.id))
else:
duration = durations[0]
for i, offset in enumerate(range(0, duration, chapter_gen_interval)):
start, end = offset, offset + chapter_gen_interval
chapter = metadata.chapters.new()
chapter.title = 'Chapter {i}'.format(i=(i + 1))
chapter.start_time_offset = start
chapter.end_time_offset = end if end < duration else duration

# Clear Ratings
metadata.rating = 0.0
Expand Down
16 changes: 11 additions & 5 deletions Contents/Code/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@
]

# File Extensions
VIDEO_EXTENSIONS = ('.mp4', '.m4v', '.mkv', '.wmv', '.avi',
'.flv', '.mov', '.3gp', '.rm', '.rmvb',
'.ts', '.m2ts', '.mpegts', '.mpeg')
SUBTITLE_EXTENSIONS = ('.srt', '.ass', '.ssa', '.smi',
'.sub', '.idx', '.vtt', '.psb')
SUBTITLE_EXTENSIONS = ('.utf', '.utf8', '.utf-8', '.srt', '.smi',
'.rt', '.ssa', '.aqt', '.jss', '.ass',
'.idx', '.sub', '.txt', '.psb', '.vtt')
VIDEO_EXTENSIONS = ('.3g2', '.3gp', '.asf', '.asx', '.avc', '.avi',
'.avs', '.bivx', '.bup', '.divx', '.dv', '.dvr-ms',
'.evo', '.fli', '.flv', '.m2t', '.m2ts', '.m2v',
'.m4v', '.mkv', '.mov', '.mp4', '.mpeg', '.mpg',
'.mts', '.nsv', '.nuv', '.ogm', '.ogv', '.tp',
'.pva', '.qt', '.rm', '.rmvb', '.sdp', '.svq3',
'.strm', '.ts', '.ty', '.vdr', '.viv', '.vob',
'.vp3', '.wmv', '.wpl', '.wtv', '.xsp', '.xvid', '.webm')

# Preference Keys
KEY_API_SERVER = 'api_server'
Expand Down

0 comments on commit 91eecd9

Please sign in to comment.