mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +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
|
from ..cache import cache, memcache
|
||||||
import itertools
|
import itertools
|
||||||
import binascii
|
import binascii
|
||||||
import json
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
BASE_PATTERN = r"(?:https?://)?(?:www\.)?instagram\.com"
|
BASE_PATTERN = r"(?:https?://)?(?:www\.)?instagram\.com"
|
||||||
@ -913,7 +912,7 @@ class InstagramGraphqlAPI():
|
|||||||
self.user_collection = self.user_saved = self.reels_media = \
|
self.user_collection = self.user_saved = self.reels_media = \
|
||||||
self.highlights_media = self.guide = self.guide_media = \
|
self.highlights_media = self.guide = self.guide_media = \
|
||||||
self._unsupported
|
self._unsupported
|
||||||
self._json_dumps = json.JSONEncoder(separators=(",", ":")).encode
|
self._json_dumps = util.json_dumps
|
||||||
|
|
||||||
api = InstagramRestAPI(extractor)
|
api = InstagramRestAPI(extractor)
|
||||||
self.user_by_name = api.user_by_name
|
self.user_by_name = api.user_by_name
|
||||||
|
@ -13,7 +13,6 @@ from .. import text, util, exception
|
|||||||
from ..cache import cache, memcache
|
from ..cache import cache, memcache
|
||||||
import itertools
|
import itertools
|
||||||
import random
|
import random
|
||||||
import json
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
BASE_PATTERN = (r"(?:https?://)?(?:www\.|mobile\.)?"
|
BASE_PATTERN = (r"(?:https?://)?(?:www\.|mobile\.)?"
|
||||||
@ -1034,7 +1033,7 @@ class TwitterAPI():
|
|||||||
|
|
||||||
self.root = "https://x.com/i/api"
|
self.root = "https://x.com/i/api"
|
||||||
self._nsfw_warning = True
|
self._nsfw_warning = True
|
||||||
self._json_dumps = json.JSONEncoder(separators=(",", ":")).encode
|
self._json_dumps = util.json_dumps
|
||||||
|
|
||||||
cookies = extractor.cookies
|
cookies = extractor.cookies
|
||||||
cookies_domain = extractor.cookies_domain
|
cookies_domain = extractor.cookies_domain
|
||||||
|
@ -253,7 +253,11 @@ def json_default(obj):
|
|||||||
|
|
||||||
|
|
||||||
json_loads = json._default_decoder.decode
|
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):
|
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}", datetime.datetime(2010, 1, 1))
|
||||||
self._run_test("{t!d:%Y-%m-%d}", "2010-01-01")
|
self._run_test("{t!d:%Y-%m-%d}", "2010-01-01")
|
||||||
self._run_test("{dt!T}", "1262304000")
|
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("{dt!j}", '"2010-01-01 00:00:00"')
|
||||||
self._run_test("{a!g}", "hello-world")
|
self._run_test("{a!g}", "hello-world")
|
||||||
self._run_test("{a!L}", 11)
|
self._run_test("{a!L}", 11)
|
||||||
|
Loading…
Reference in New Issue
Block a user