Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skip-lost argument to solve issue #3 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions sponsrdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ def dump(
text: Union[bool, str] = True,
text_to_video: bool = True,
prefer_video: VideoPreference = VideoPreference(),
skip_lost: bool = False,
):

LOGGER.info(f'Start dump using preference: {prefer_video} ...')
Expand Down Expand Up @@ -620,9 +621,13 @@ def dump(
try:
self._download_file(filepath, dest=dest_filename, prefer_video=prefer_video)

except HTTPError:
except HTTPError as err:
LOGGER.debug(f'{pformat(file_info, indent=2)}')
raise
if skip_lost and err.response.status_code == 404:
LOGGER.warning(f'File {filepath} not found, skip')
filename += ' [skipped]'
else:
raise

else:
dest_filename = TextConverter.spawn(
Expand Down Expand Up @@ -662,6 +667,8 @@ def dump(
'--no-text', help='Не следует скачивать текст', action='store_true')
parser.add_argument(
'--text-to-video', help='Следует ли создать видео с текстом статьи', action='store_true')
parser.add_argument(
'--skip-lost', help='Пропускать не найденные файлы (error 404)', action='store_true')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it ignore-missing to be more precise and semantically correct.

И «ненайдённые» в данном случае слитно.


args = parser.parse_args()

Expand All @@ -681,5 +688,6 @@ def dump(
audio=not args.no_audio,
video=not args.no_video,
text=not args.no_text,
text_to_video=args.text_to_video
text_to_video=args.text_to_video,
skip_lost=args.skip_lost
)