Skip to content

Commit

Permalink
Proofread "download" plugin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Mar 10, 2024
1 parent 0d9f52c commit 952deae
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions avtdl/plugins/file/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Plugins.register('download', Plugins.kind.ACTOR_CONFIG)
class FileDownloadConfig(ActorConfig):
max_concurrent_downloads: int = Field(default=1, ge=1)
"""limit for simultaneously active download tasks among all entities. Note, that each entity will still process records sequentially regardless of this setting"""
"""limit for simultaneously active download tasks among all entities. Note that each entity will still process records sequentially regardless of this setting"""
partial_file_suffix: str = '.part'
"""appended to a name of the file that is not yet completely downloaded"""

Expand All @@ -38,7 +38,7 @@ class FileDownloadEntity(ActionEntity):
overwrite: bool = False
"""whether file should be overwritten in if it already exists. If set to false will cause suffix with a number be added to the newly downloaded file name"""
rename_suffix: str = ' [{i}]'
"""when overwriting is disabled, this suffix is attached to base filename with the "{i}" part replaced with a number. Must contain "{i}" exactly once"""
"""when overwriting is disabled, this suffix is attached to the base filename with the "{i}" part replaced with a number. Must contain "{i}" exactly once"""

@field_validator('extension')
@classmethod
Expand All @@ -54,7 +54,7 @@ def ensure_dot(cls, value: Optional[str]) -> Optional[str]:
def check_suffix(cls, value: str) -> str:
found = len(re.findall(r'{i}', value))
if found != 1:
raise ValueError('rename_suffix must contain exactly one occurrence of "{i}", got ' + str(found))
raise ValueError('rename_suffix must contain exactly one occurrence of "{i}", got ' + str(found))
value = sanitize_filename(value)
return value

Expand All @@ -63,24 +63,26 @@ class FileDownload(Action):
"""
Download a file
Take an url from a record field and download it as a file to specified location.
Field must contain a valid url with a scheme or a list of such urls.
Take an url from a field of a processed record with a name specified in `url_field`
and download it as a file to specified location.
The field must be present in the record and must contain a valid url with a scheme
(such as "https") or a list of such urls.
Primarily designed for downloading images, attached to a post, or thumbnails.
Does not support resuming interrupted download or detecting that this exact file is
Primarily designed for downloading images attached to a post, or thumbnails.
Does not support resuming interrupted downloads or detecting that this exact file is
already stored at target location without downloading it again.
File extension and name are inferred from HTTP headers and path part of the url,
unless provided explicitly with `extension` and `filename` parameters.
Since final file name is determined as part of the download process, the file
is initially stored under temporary name (currently an sha1 of the url) in the
Since final file name is determined as a part of the download process, the file
is initially stored under a temporary name (currently an SHA1 of the url) in the
download directory, and then renamed to target filename.
If file with given name already exists, based on `overwrite` setting new file will either
If a file with given name already exists, depending on an `overwrite` setting a new file will either
overwrite it or get stored under different name, generated by combining
base name with a number added as part of `rename_suffix`.
If, however, exact copy of the new file is found among files in target directory
sharing base name, the new file will be deleted, giving preference to existing copy.
the base name with a number added as part of `rename_suffix`.
If, however, an exact copy of the new file is found among the files in target directory
sharing the base name, the new file will be deleted, giving preference to the existing copy.
"""

def __init__(self, conf: FileDownloadConfig, entities: Sequence[FileDownloadEntity]):
Expand Down

0 comments on commit 952deae

Please sign in to comment.