Skip to content

Conversation

@michaelos443
Copy link
Owner

Summary

This PR refactors the extractor.py module to reduce code duplication, improve docstring clarity, and ensure PEP8 compliance.

Changes

Code Duplication Reduction

  • _init_base_attributes() - Helper function to consolidate common initialization logic shared between Extractor and VideoExtractor classes
  • _get_stream() - Centralizes logic for retrieving stream info from either streams or dash_streams
  • _run_download() - Consolidates the nearly identical code from download_by_url and download_by_vid
  • _sort_streams() - Extracts the complex stream sorting logic
  • _get_stream_id_key() - Eliminates the repeated stream['id'] if 'id' in stream else stream['itag'] pattern
  • _select_best_stream_id() - Extracts best stream selection logic
  • _save_auxiliary_files() - Consolidates danmaku and lyrics file saving

PEP8 Compliance

  • Fixed all lines exceeding 79 characters
  • Changed bare except: to specific except KeyError:
  • Removed commented-out code
  • Removed unused imports (match1, get_content)

Docstring Improvements

  • Added comprehensive module docstring
  • Added class docstrings with attribute documentation
  • Added method docstrings with Args and Returns sections
  • Used Google-style docstring format consistently

Pull Request opened by Augment Code with guidance from the PR author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants