smaller changes, missing docs, etc.

- make 'netrc' extractor-specific
- rename 'downloader.enable' to 'enabled'
- document 'downloader.ytdl.format'
- consistent newlines in configuration.rst
This commit is contained in:
Mike Fährmann
2018-11-16 18:02:24 +01:00
parent b17a5d6f3b
commit c47482b110
3 changed files with 50 additions and 32 deletions

View File

@@ -13,9 +13,11 @@ Contents
7) `API Tokens & IDs`_ 7) `API Tokens & IDs`_
Extractor Options Extractor Options
================= =================
Each extractor is identified by its ``category`` and ``subcategory``. Each extractor is identified by its ``category`` and ``subcategory``.
The ``category`` is the lowercase site name without any spaces or special The ``category`` is the lowercase site name without any spaces or special
characters, which is usually just the module name characters, which is usually just the module name
@@ -155,6 +157,15 @@ Description The username and password to use when attempting to log in to
=========== ===== =========== =====
extractor.*.netrc
-----------------
=========== =====
Type ``bool``
Default ``false``
Description Enable the use of |.netrc|_ authentication data.
=========== =====
extractor.*.cookies extractor.*.cookies
------------------- -------------------
=========== ===== =========== =====
@@ -356,9 +367,11 @@ Description Like `image-filter`__, but applies to delegated URLs
__ `extractor.*.image-filter`_ __ `extractor.*.image-filter`_
Extractor-specific Options Extractor-specific Options
========================== ==========================
extractor.artstation.external extractor.artstation.external
----------------------------- -----------------------------
=========== ===== =========== =====
@@ -769,8 +782,18 @@ Description Categorize tags by their respective types
Downloader Options Downloader Options
================== ==================
downloader.part
--------------- downloader.*.enabled
--------------------
=========== =====
Type ``bool``
Default ``true``
Description Enable/Disable this downloader module.
=========== =====
downloader.*.part
-----------------
=========== ===== =========== =====
Type ``bool`` Type ``bool``
Default ``true`` Default ``true``
@@ -784,8 +807,8 @@ Description Controls the use of ``.part`` files during file downloads.
=========== ===== =========== =====
downloader.part-directory downloader.*.part-directory
------------------------- ---------------------------
=========== ===== =========== =====
Type |Path|_ Type |Path|_
Default ``null`` Default ``null``
@@ -797,8 +820,8 @@ Description Alternate location for ``.part`` files.
=========== ===== =========== =====
downloader.rate downloader.*.rate
--------------- -----------------
=========== ===== =========== =====
Type ``string`` Type ``string``
Default ``null`` Default ``null``
@@ -811,8 +834,8 @@ Description Maximum download rate in bytes per second.
=========== ===== =========== =====
downloader.retries downloader.*.retries
------------------ --------------------
=========== ===== =========== =====
Type ``integer`` Type ``integer``
Default `extractor.*.retries`_ Default `extractor.*.retries`_
@@ -820,8 +843,8 @@ Description Number of retries during file downloads.
=========== ===== =========== =====
downloader.timeout downloader.*.timeout
------------------ --------------------
=========== ===== =========== =====
Type ``float`` or ``null`` Type ``float`` or ``null``
Default `extractor.*.timeout`_ Default `extractor.*.timeout`_
@@ -829,8 +852,8 @@ Description Connection timeout during file downloads.
=========== ===== =========== =====
downloader.verify downloader.*.verify
----------------- -------------------
=========== ===== =========== =====
Type ``bool`` or ``string`` Type ``bool`` or ``string``
Default `extractor.*.verify`_ Default `extractor.*.verify`_
@@ -838,12 +861,14 @@ Description Certificate validation during file downloads.
=========== ===== =========== =====
downloader.*.enable downloader.ytdl.format
------------------- ----------------------
=========== ===== =========== =====
Type ``bool`` Type ``string``
Default ``true`` Default youtube-dl's default, currently ``"bestvideo+bestaudio/best"``
Description Enable/Disable this downloader module. Description Video `format selection
<https://github.com/rg3/youtube-dl#format-selection>`__
directly passed to youtube-dl.
=========== ===== =========== =====
@@ -882,6 +907,7 @@ Description | Additional options passed directly to the ``YoutubeDL`` constructo
Output Options Output Options
============== ==============
output.mode output.mode
----------- -----------
=========== ===== =========== =====
@@ -1053,7 +1079,6 @@ Default ``"ffmpeg"``
Description Location of the ``ffmpeg`` (or ``avconv``) executable to use. Description Location of the ``ffmpeg`` (or ``avconv``) executable to use.
=========== ===== =========== =====
ugoira.ffmpeg-output ugoira.ffmpeg-output
-------------------- --------------------
=========== ===== =========== =====
@@ -1145,14 +1170,6 @@ Description Keep the actual files after writing them to a ZIP archive.
Miscellaneous Options Miscellaneous Options
===================== =====================
netrc
-----
=========== =====
Type ``bool``
Default ``false``
Description Enable the use of |.netrc|_ authentication data.
=========== =====
cache.file cache.file
---------- ----------
@@ -1171,6 +1188,7 @@ Description Path of the SQLite3 database used to cache login sessions,
API Tokens & IDs API Tokens & IDs
================ ================
All configuration keys listed in this section have fully functional default All configuration keys listed in this section have fully functional default
values embedded into *gallery-dl* itself, but if things unexpectedly break values embedded into *gallery-dl* itself, but if things unexpectedly break
or you want to use your own personal client credentials, you can follow these or you want to use your own personal client credentials, you can follow these

View File

@@ -60,6 +60,7 @@ class Extractor():
retries = retries or self._retries retries = retries or self._retries
kwargs.setdefault("timeout", self._timeout) kwargs.setdefault("timeout", self._timeout)
kwargs.setdefault("verify", self._verify) kwargs.setdefault("verify", self._verify)
while True: while True:
try: try:
response = self.session.request(method, url, **kwargs) response = self.session.request(method, url, **kwargs)
@@ -74,14 +75,13 @@ class Extractor():
response.encoding = encoding response.encoding = encoding
return response return response
msg = "{}: {} for url: {}".format( msg = "{}: {} for url: {}".format(code, response.reason, url)
code, response.reason, url)
if code < 500 and code != 429: if code < 500 and code != 429:
break break
self.log.debug("%s (%d/%d)", msg, tries + 1, retries)
if tries >= retries: if tries >= retries:
break break
self.log.debug("%s (%d/%d)", msg, tries + 1, retries)
time.sleep(2 ** tries) time.sleep(2 ** tries)
tries += 1 tries += 1
@@ -94,7 +94,7 @@ class Extractor():
if username: if username:
password = self.config("password") password = self.config("password")
elif config.get(("netrc",), False): elif self.config("netrc", False):
try: try:
info = netrc.netrc().authenticators(self.category) info = netrc.netrc().authenticators(self.category)
username, _, password = info username, _, password = info

View File

@@ -272,11 +272,11 @@ class DownloadJob(Job):
pass pass
klass = downloader.find(scheme) klass = downloader.find(scheme)
if klass and config.get(("downloader", scheme, "enable"), True): if klass and config.get(("downloader", scheme, "enabled"), True):
instance = klass(self.extractor, self.out) instance = klass(self.extractor, self.out)
else: else:
instance = None instance = None
self.log.error("'%s:' URLs are not supported", scheme) self.log.error("'%s:' URLs are not supported/enabled", scheme)
self.downloaders[scheme] = instance self.downloaders[scheme] = instance
return instance return instance