Write metadata to .info.json when requested
This commit is contained in:
1 file changed
+8
-3
@@ -12,13 +12,13 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
log.info('Syncing missing metadata...')
|
log.info('Syncing missing metadata...')
|
||||||
sources = Source.objects.filter(Q(copy_thumbnails=True) | Q(write_nfo=True))
|
sources = Source.objects.filter(Q(copy_thumbnails=True) | Q(write_json=True) | Q(write_nfo=True))
|
||||||
for source in sources.order_by('name'):
|
for source in sources.order_by('name'):
|
||||||
log.info(f'Finding media for source: {source}')
|
log.info(f'Finding media for source: {source}')
|
||||||
for item in Media.objects.filter(source=source, downloaded=True):
|
for item in Media.objects.filter(source=source, downloaded=True):
|
||||||
log.info(f'Checking media for missing metadata: {source} / {item}')
|
log.info(f'Checking media for missing metadata: {source} / {item}')
|
||||||
thumbpath = item.thumbpath
|
thumbpath = item.thumbpath
|
||||||
if not thumbpath.is_file():
|
if source.copy_thumbnails and not thumbpath.is_file():
|
||||||
if item.thumb:
|
if item.thumb:
|
||||||
log.info(f'Copying missing thumbnail from: {item.thumb.path} '
|
log.info(f'Copying missing thumbnail from: {item.thumb.path} '
|
||||||
f'to: {thumbpath}')
|
f'to: {thumbpath}')
|
||||||
@@ -27,7 +27,12 @@ class Command(BaseCommand):
|
|||||||
log.error(f'Tried to copy missing thumbnail for {item} but '
|
log.error(f'Tried to copy missing thumbnail for {item} but '
|
||||||
f'the thumbnail has not been downloaded')
|
f'the thumbnail has not been downloaded')
|
||||||
nfopath = item.nfopath
|
nfopath = item.nfopath
|
||||||
if not nfopath.is_file():
|
if source.write_nfo and not nfopath.is_file():
|
||||||
log.info(f'Writing missing NFO file: {nfopath}')
|
log.info(f'Writing missing NFO file: {nfopath}')
|
||||||
write_text_file(nfopath, item.nfoxml)
|
write_text_file(nfopath, item.nfoxml)
|
||||||
|
jsonpath = item.jsonpath
|
||||||
|
if source.write_json and item.has_metadata and not jsonpath.is_file():
|
||||||
|
log.info(f'Writing missing JSON file: {jsonpath}')
|
||||||
|
write_text_file(jsonpath, item.metadata_dumps())
|
||||||
|
|
||||||
log.info('Done')
|
log.info('Done')
|
||||||
Reference in new issue
Block a user