[nitter] use 'gallery-dl/<version>' User-Agent (#7045 #8130 #8409)

This commit is contained in:
Mike Fährmann
2026-01-21 18:07:47 +01:00
parent 78da7edde8
commit 63df6423bf
3 changed files with 15 additions and 9 deletions

View File

@@ -514,6 +514,7 @@ Default
``hdoujin`` | ``hdoujin`` |
``itaku`` | ``itaku`` |
``newgrounds`` | ``newgrounds`` |
``[nitter]`` |
``[philomena]`` | ``[philomena]`` |
``pixiv-novel`` | ``pixiv-novel`` |
``plurk`` | ``plurk`` |
@@ -802,6 +803,7 @@ Default
``"gallery-dl/VERSION"`` ``"gallery-dl/VERSION"``
* ``[Danbooru]`` * ``[Danbooru]``
* ``mangadex`` * ``mangadex``
* ``[nitter]``
* ``weasyl`` * ``weasyl``
* ``[wikimedia]`` * ``[wikimedia]``
* ``zerochan`` * ``zerochan``
@@ -4487,8 +4489,8 @@ Note
It is possible to use ``"all"`` instead of listing all values separately. It is possible to use ``"all"`` instead of listing all values separately.
extractor.nitter.quoted extractor.[nitter].quoted
----------------------- -------------------------
Type Type
``bool`` ``bool``
Default Default
@@ -4497,8 +4499,8 @@ Description
Fetch media from quoted Tweets. Fetch media from quoted Tweets.
extractor.nitter.retweets extractor.[nitter].retweets
------------------------- ---------------------------
Type Type
``bool`` ``bool``
Default Default
@@ -4507,8 +4509,8 @@ Description
Fetch media from Retweets. Fetch media from Retweets.
extractor.nitter.videos extractor.[nitter].videos
----------------------- -------------------------
Type Type
* ``bool`` * ``bool``
* ``string`` * ``string``

View File

@@ -1139,6 +1139,8 @@
"nitter": "nitter":
{ {
"sleep-request": "0.5-1.5",
"quoted" : false, "quoted" : false,
"retweets": false, "retweets": false,
"videos" : true "videos" : true

View File

@@ -9,16 +9,18 @@
"""Extractors for Nitter instances""" """Extractors for Nitter instances"""
from .common import BaseExtractor, Message from .common import BaseExtractor, Message
from .. import text from .. import text, util
import binascii import binascii
class NitterExtractor(BaseExtractor): class NitterExtractor(BaseExtractor):
"""Base class for nitter extractors""" """Base class for nitter extractors"""
basecategory = "nitter" basecategory = "nitter"
directory_fmt = ("{category}", "{user[name]}") directory_fmt = ("nitter", "{user[name]}")
filename_fmt = "{tweet_id}_{num}.{extension}" filename_fmt = "{tweet_id}_{num}.{extension}"
archive_fmt = "{tweet_id}_{num}" archive_fmt = "{tweet_id}_{num}"
useragent = util.USERAGENT_GALLERYDL
request_interval = (0.5, 1.5)
def __init__(self, match): def __init__(self, match):
self.cookies_domain = self.root.partition("://")[2] self.cookies_domain = self.root.partition("://")[2]
@@ -271,7 +273,7 @@ class NitterSearchExtractor(NitterExtractor):
class NitterTweetExtractor(NitterExtractor): class NitterTweetExtractor(NitterExtractor):
"""Extractor for nitter tweets""" """Extractor for nitter tweets"""
subcategory = "tweet" subcategory = "tweet"
directory_fmt = ("{category}", "{user[name]}") directory_fmt = ("nitter", "{user[name]}")
filename_fmt = "{tweet_id}_{num}.{extension}" filename_fmt = "{tweet_id}_{num}.{extension}"
archive_fmt = "{tweet_id}_{num}" archive_fmt = "{tweet_id}_{num}"
pattern = BASE_PATTERN + r"/(i/web|[^/?#]+)/status/(\d+())" pattern = BASE_PATTERN + r"/(i/web|[^/?#]+)/status/(\d+())"