mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 04:46:18 -05:00
Sorting keys when saving json file.
This commit is contained in:
parent
305764ee38
commit
0bee458b79
7 changed files with 70 additions and 82 deletions
|
|
@ -163,13 +163,13 @@ async def model_archive_result(url: str, singlefile: str, readability: dict, scr
|
|||
|
||||
if readability:
|
||||
# Write the readability parts to their own files. Write what is left after pops to the JSON file.
|
||||
with archive_files.readability.open('wt') as fh:
|
||||
with archive_files.readability.open('wt') as fp:
|
||||
content = format_html_string(readability.pop('content'))
|
||||
fh.write(content)
|
||||
with archive_files.readability_txt.open('wt') as fh:
|
||||
fp.write(content)
|
||||
with archive_files.readability_txt.open('wt') as fp:
|
||||
readability_txt = readability.pop('textContent')
|
||||
readability_txt = split_lines_by_length(readability_txt)
|
||||
fh.write(readability_txt)
|
||||
fp.write(readability_txt)
|
||||
else:
|
||||
# No readability was returned, so there are no files.
|
||||
archive_files.readability_txt = archive_files.readability = None
|
||||
|
|
@ -186,8 +186,8 @@ async def model_archive_result(url: str, singlefile: str, readability: dict, scr
|
|||
# Always write a JSON file that contains at least the URL.
|
||||
readability = readability or {}
|
||||
readability['url'] = url
|
||||
with archive_files.readability_json.open('wt') as fh:
|
||||
fh.write(json.dumps(readability, indent=2))
|
||||
with archive_files.readability_json.open('wt') as fp:
|
||||
json.dump(readability, fp, indent=2, sort_keys=True)
|
||||
|
||||
# Create any File models that we can, index them all.
|
||||
paths = (
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ def update_channel_catalog(channel: Channel, info: dict):
|
|||
if channel.directory:
|
||||
info_json_path = channel.directory / f'{channel.name}.info.json'
|
||||
with info_json_path.open('wt') as fh:
|
||||
json.dump(info, fh, indent=2)
|
||||
json.dump(info, fh, indent=2, sort_keys=True)
|
||||
logger.debug(f'Wrote channel info json to {info_json_path}')
|
||||
else:
|
||||
logger.debug(f'Skipping channel info json because it does not have a directory: {channel}')
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from sqlalchemy.orm.collections import InstrumentedList
|
|||
|
||||
from modules.videos.errors import UnknownVideo, UnknownChannel
|
||||
from wrolpi.captions import read_captions
|
||||
from wrolpi.common import Base, ModelHelper, logger, get_media_directory, background_task
|
||||
from wrolpi.common import Base, ModelHelper, logger, get_media_directory, background_task, replace_file
|
||||
from wrolpi.db import get_db_curs, get_db_session, optional_session
|
||||
from wrolpi.downloader import Download, download_manager
|
||||
from wrolpi.files.lib import refresh_files, split_path_stem_and_suffix, replace_file
|
||||
from wrolpi.files.lib import refresh_files, split_path_stem_and_suffix
|
||||
from wrolpi.files.models import FileGroup
|
||||
from wrolpi.media_path import MediaPathType
|
||||
from wrolpi.tags import Tag, TagFile
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue