mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-21 18:22:30 +01:00
[util] use minimal separators for 'json_dumps()'
This commit is contained in:
parent
ed859f05ed
commit
a120295632
@ -14,7 +14,6 @@ from .. import text, util, exception
|
||||
from ..cache import cache, memcache
|
||||
import itertools
|
||||
import binascii
|
||||
import json
|
||||
import re
|
||||
|
||||
BASE_PATTERN = r"(?:https?://)?(?:www\.)?instagram\.com"
|
||||
@ -913,7 +912,7 @@ class InstagramGraphqlAPI():
|
||||
self.user_collection = self.user_saved = self.reels_media = \
|
||||
self.highlights_media = self.guide = self.guide_media = \
|
||||
self._unsupported
|
||||
self._json_dumps = json.JSONEncoder(separators=(",", ":")).encode
|
||||
self._json_dumps = util.json_dumps
|
||||
|
||||
api = InstagramRestAPI(extractor)
|
||||
self.user_by_name = api.user_by_name
|
||||
|
@ -13,7 +13,6 @@ from .. import text, util, exception
|
||||
from ..cache import cache, memcache
|
||||
import itertools
|
||||
import random
|
||||
import json
|
||||
import re
|
||||
|
||||
BASE_PATTERN = (r"(?:https?://)?(?:www\.|mobile\.)?"
|
||||
@ -1034,7 +1033,7 @@ class TwitterAPI():
|
||||
|
||||
self.root = "https://x.com/i/api"
|
||||
self._nsfw_warning = True
|
||||
self._json_dumps = json.JSONEncoder(separators=(",", ":")).encode
|
||||
self._json_dumps = util.json_dumps
|
||||
|
||||
cookies = extractor.cookies
|
||||
cookies_domain = extractor.cookies_domain
|
||||
|
@ -253,7 +253,11 @@ def json_default(obj):
|
||||
|
||||
|
||||
json_loads = json._default_decoder.decode
|
||||
json_dumps = json.JSONEncoder(default=json_default).encode
|
||||
json_dumps = json.JSONEncoder(
|
||||
check_circular=False,
|
||||
separators=(",", ":"),
|
||||
default=json_default,
|
||||
).encode
|
||||
|
||||
|
||||
def dump_json(obj, fp=sys.stdout, ensure_ascii=True, indent=4):
|
||||
|
@ -64,7 +64,7 @@ class TestFormatter(unittest.TestCase):
|
||||
self._run_test("{t!d}", datetime.datetime(2010, 1, 1))
|
||||
self._run_test("{t!d:%Y-%m-%d}", "2010-01-01")
|
||||
self._run_test("{dt!T}", "1262304000")
|
||||
self._run_test("{l!j}", '["a", "b", "c"]')
|
||||
self._run_test("{l!j}", '["a","b","c"]')
|
||||
self._run_test("{dt!j}", '"2010-01-01 00:00:00"')
|
||||
self._run_test("{a!g}", "hello-world")
|
||||
self._run_test("{a!L}", 11)
|
||||
|
Loading…
Reference in New Issue
Block a user