How aapatre/automatic-udemy-course-enroller-get-paid-udemy-courses-for-free works
Project Type and Purpose
• This is a Python-based command-line automation tool (“udemy-enroller”) whose job is to scrape coupon links from multiple third-party websites and then automatically enroll the user into Udemy courses (via REST or Selenium), all orchestrated via a CLI.
• It is not a web-app or service; rather, it is a full CLI application with modular plugins (scrapers) and a small persistence layer for user settings.
High-Level Component Breakdown
a. CLI Layer
• udemy_enroller/cli.py: Bootstraps the application, parses flags, dispatches to the runner.
b. Core Orchestration
• udemy_enroller/runner.py: Coordinates the overall flow: load settings, spin up scraper manager, process results, accumulate stats, and output a summary.
• udemy_enroller/driver_manager.py: Abstracts Selenium or other browser driver instantiation (Chrome, Firefox).
c. Scraper Plugin System
• udemy_enroller/scrapers/manager.py: Discovers and invokes the chosen subset of scrapers.
• udemy_enroller/scrapers/base_scraper.py: Defines the interface for all site scrapers.
• Site-specific modules (coursevania.py, discudemy.py, tutorialbar.py, freebiesglobal.py, idownloadcoupon.py) implement that interface.
d. Enrollment Subsystem
• udemy_enroller/udemy_rest.py: Handles REST calls to Udemy’s API for authentication and enrollment.
• udemy_enroller/udemy_ui.py: (Optionally) automates UI enrollment for workflows not supported by REST.
e. Utilities and Supporting Modules
• http_utils.py: Common HTTP wrapper (retry, headers, sessions).
• settings.py + sample_settings.yaml: Reads/writes user preferences and credentials (persisted under ~/.udemy_enroller).
• logger.py: Central logging and debug output.
• exceptions.py: Custom exception types.
• utils.py: Miscellaneous helpers (e.g., parsing URLs, formatting).
f. Persistence
• Settings File on disk: YAML file in user’s home directory.
• Cookies (optional) stored alongside settings for session reuse.
g. External Systems
• Coupon Sites: tutorialbar.com, discudemy.com, etc.
• Udemy: REST API or web UI.
• Browser Driver: ChromeDriver/GeckoDriver (if UI automation is used).
Relationships and Data Flow
• User invokes udemy_enroller → CLI parses arguments and calls Runner.
• Runner loads settings → instantiates DriverManager (if UI needed) → passes browser handle to scrapers.
• Runner invokes ScraperManager → each scraper uses HTTP Utils (or driver) to fetch coupon pages → returns a list of (course_url, coupon_code).
• Runner deduplicates, filters (language, category) → for each eligible course: calls UdemyRest or UdemyUI to enroll → updates statistics.
• Runner writes updated settings/cookies and prints final stats.
Architectural Patterns and Principles
• Plugin Pattern for scrapers: New sites only require dropping a new module under /scrapers and registering it.
• Separation of Concerns: CLI, orchestration (Runner), scraping, enrollment, and configuration are all in distinct modules.
• Dependency Injection: Runner passes shared components (HTTP session, driver, logger) into scrapers.
• Configuration over Code: Behavior is driven by command-line flags and settings.yaml, not by hard-coding.
• Multiple scrapers under a “Scraper Plugin” boundary.
• Settings file as a persistent data store.
• Asynchronous or retry logic in HTTP utils if desired.