feat: Undo bogus formatting changes
This commit is contained in:
@@ -261,7 +261,7 @@ async def add(request):
|
||||
if split_by_chapters is None:
|
||||
split_by_chapters = False
|
||||
if chapter_template is None:
|
||||
chapter_template = '%(section_number)02d - %(section_title)s.%(ext)s'
|
||||
chapter_template = '%(title)s - %(section_number)02d - %(section_title)s.%(ext)s'
|
||||
|
||||
playlist_item_limit = int(playlist_item_limit)
|
||||
|
||||
|
||||
@@ -100,8 +100,6 @@ class Download:
|
||||
)})
|
||||
|
||||
def put_status_postprocessor(d):
|
||||
log.debug(f"Postprocessor hook called: postprocessor={d.get('postprocessor')}, status={d.get('status')}")
|
||||
|
||||
if d['postprocessor'] == 'MoveFiles' and d['status'] == 'finished':
|
||||
if '__finaldir' in d['info_dict']:
|
||||
filename = os.path.join(d['info_dict']['__finaldir'], os.path.basename(d['info_dict']['filepath']))
|
||||
@@ -217,7 +215,7 @@ class Download:
|
||||
self.info.chapter_files = []
|
||||
rel_path = os.path.relpath(chapter_file, self.download_dir)
|
||||
file_size = os.path.getsize(chapter_file) if os.path.exists(chapter_file) else None
|
||||
# Upsert: update if exists, otherwise append. Postprocessor hook called multiple times with chapters.
|
||||
#Postprocessor hook called multiple times with chapters. Only insert if not already present.
|
||||
existing = next((cf for cf in self.info.chapter_files if cf['filename'] == rel_path), None)
|
||||
if not existing:
|
||||
self.info.chapter_files.append({'filename': rel_path, 'size': file_size})
|
||||
@@ -464,7 +462,7 @@ class DownloadQueue:
|
||||
return {'status': 'ok'}
|
||||
return {'status': 'error', 'msg': f'Unsupported resource "{etype}"'}
|
||||
|
||||
async def add(self, url, quality, format, folder, custom_name_prefix, playlist_strict_mode, playlist_item_limit, auto_start=True, split_by_chapters=False, chapter_template='%(section_number)02d - %(section_title)s.%(ext)s', already=None):
|
||||
async def add(self, url, quality, format, folder, custom_name_prefix, playlist_strict_mode, playlist_item_limit, auto_start=True, split_by_chapters=False, chapter_template='%(title)s - %(section_number)02d - %(section_title)s.%(ext)s', already=None):
|
||||
log.info(f'adding {url}: {quality=} {format=} {already=} {folder=} {custom_name_prefix=} {playlist_strict_mode=} {playlist_item_limit=} {auto_start=} {split_by_chapters=} {chapter_template=}')
|
||||
already = set() if already is None else already
|
||||
if url in already:
|
||||
|
||||
@@ -472,6 +472,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -106,7 +106,7 @@ export class App implements AfterViewInit, OnInit {
|
||||
this.quality = this.cookieService.get('metube_quality') || 'best';
|
||||
this.autoStart = this.cookieService.get('metube_auto_start') !== 'false';
|
||||
this.splitByChapters = this.cookieService.get('metube_split_chapters') === 'true';
|
||||
this.chapterTemplate = this.cookieService.get('metube_chapter_template') || '%(section_number)02d - %(section_title)s.%(ext)s';
|
||||
this.chapterTemplate = this.cookieService.get('metube_chapter_template') || '%(title)s - %(section_number)02d - %(section_title)s.%(ext)s';
|
||||
|
||||
this.activeTheme = this.getPreferredTheme(this.cookieService);
|
||||
|
||||
@@ -269,6 +269,10 @@ export class App implements AfterViewInit, OnInit {
|
||||
}
|
||||
|
||||
chapterTemplateChanged() {
|
||||
// Restore default if template is cleared
|
||||
if (!this.chapterTemplate || this.chapterTemplate.trim() === '') {
|
||||
this.chapterTemplate = '%(title)s - %(section_number)02d - %(section_title)s.%(ext)s';
|
||||
}
|
||||
this.cookieService.set('metube_chapter_template', this.chapterTemplate, { expires: 3650 });
|
||||
}
|
||||
|
||||
@@ -304,6 +308,12 @@ export class App implements AfterViewInit, OnInit {
|
||||
splitByChapters = splitByChapters ?? this.splitByChapters
|
||||
chapterTemplate = chapterTemplate ?? this.chapterTemplate
|
||||
|
||||
// Validate chapter template if chapter splitting is enabled
|
||||
if (splitByChapters && !chapterTemplate.includes('%(section_number)')) {
|
||||
alert('Chapter template must include %(section_number)');
|
||||
return;
|
||||
}
|
||||
|
||||
console.debug('Downloading: url=' + url + ' quality=' + quality + ' format=' + format + ' folder=' + folder + ' customNamePrefix=' + customNamePrefix + ' playlistStrictMode=' + playlistStrictMode + ' playlistItemLimit=' + playlistItemLimit + ' autoStart=' + autoStart + ' splitByChapters=' + splitByChapters + ' chapterTemplate=' + chapterTemplate);
|
||||
this.addInProgress = true;
|
||||
this.downloads.add(url, quality, format, folder, customNamePrefix, playlistStrictMode, playlistItemLimit, autoStart, splitByChapters, chapterTemplate).subscribe((status: Status) => {
|
||||
|
||||
@@ -151,7 +151,7 @@ export class DownloadsService {
|
||||
const defaultPlaylistItemLimit = 0;
|
||||
const defaultAutoStart = true;
|
||||
const defaultSplitByChapters = false;
|
||||
const defaultChapterTemplate = '%(section_number)02d - %(section_title)s.%(ext)s';
|
||||
const defaultChapterTemplate = '%(title)s - %(section_number)02d - %(section_title)s.%(ext)s';
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.add(url, defaultQuality, defaultFormat, defaultFolder, defaultCustomNamePrefix, defaultPlaylistStrictMode, defaultPlaylistItemLimit, defaultAutoStart, defaultSplitByChapters, defaultChapterTemplate)
|
||||
|
||||
Reference in New Issue
Block a user