Skip to content

Commit

Permalink
Merge pull request #373 from aapatre/develop
Browse files Browse the repository at this point in the history
Release 4.1.0
  • Loading branch information
cullzie authored May 20, 2022
2 parents 3be9230 + 4f75514 commit ba9f730
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 30 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.1.0] - 2022-05-20

### Added
- Re-added REST based enrolment

## [4.0.0] - 2021-11-12

### Added
Expand Down Expand Up @@ -99,6 +104,8 @@ can continue as normal
project running locally. Suitable for users who are not looking forward to
contribute.

[4.1.0]:
https://github.com/aapatre/Automatic-Udemy-Course-Enroller-GET-PAID-UDEMY-COURSES-for-FREE/releases/tag/v4.1.0
[4.0.0]:
https://github.com/aapatre/Automatic-Udemy-Course-Enroller-GET-PAID-UDEMY-COURSES-for-FREE/releases/tag/v4.0.0
[3.2.0]:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ Props to Davidd Sargent for making a super simple video tutorial. If you prefer
- `--discudemy`: Run the discudemy scraper only
- `--coursevania`: Run the coursevania scraper only
- `--tutorialbar`: Run the tutorialbar scraper only
- `--freebiesglobal`: Run the freebiesglobal scraper only _[New]_
- `--freebiesglobal`: Run the freebiesglobal scraper only
- `--max-pages=<NUMBER>`: Max number of pages to scrape from sites before exiting the script (default is 5)
- `--delete-settings`: Delete existing settings file
- `--delete-cookie`: Delete the cookie file if it exists _[New]_
- `--delete-cookie`: Delete the cookie file if it exists
- `--debug`: Enable debug logging


3 . Run the script in terminal with your target browser:
3 . Run the script in terminal with your target runner:

- `udemy_enroller --browser=firefox`
- `udemy_enroller`
- `udemy_enroller --browser=chrome`
- `udemy_enroller --browser=chromium`

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "automatic-udemy-course-enroller-get-paid-udemy-courses-for-free"
version = "4.0.2"
version = "4.1.0"
description = ""
authors = [""]

Expand Down Expand Up @@ -28,7 +28,7 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.bumpver]
current_version = "4.0.2"
current_version = "4.1.0"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "Bump version {old_version} -> {new_version}"
commit = true
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="udemy-enroller",
version="4.0.2",
version="4.1.0",
long_description=long_description,
long_description_content_type="text/markdown",
author="aapatre",
Expand Down
35 changes: 22 additions & 13 deletions udemy_enroller/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from udemy_enroller import ALL_VALID_BROWSER_STRINGS, DriverManager, Settings
from udemy_enroller.logging import get_logger
from udemy_enroller.runner import redeem_courses_ui
from udemy_enroller.runner import redeem_courses, redeem_courses_ui

logger = get_logger()

Expand Down Expand Up @@ -79,17 +79,26 @@ def run(
:return:
"""
settings = Settings(delete_settings, delete_cookie)

dm = DriverManager(browser=browser, is_ci_build=settings.is_ci_build)
redeem_courses_ui(
dm.driver,
settings,
freebiesglobal_enabled,
tutorialbar_enabled,
discudemy_enabled,
coursevania_enabled,
max_pages,
)
if browser:
dm = DriverManager(browser=browser, is_ci_build=settings.is_ci_build)
redeem_courses_ui(
dm.driver,
settings,
freebiesglobal_enabled,
tutorialbar_enabled,
discudemy_enabled,
coursevania_enabled,
max_pages,
)
else:
redeem_courses(
settings,
freebiesglobal_enabled,
tutorialbar_enabled,
discudemy_enabled,
coursevania_enabled,
max_pages,
)


def parse_args() -> Namespace:
Expand All @@ -102,7 +111,7 @@ def parse_args() -> Namespace:

parser.add_argument(
"--browser",
required=True,
required=False,
type=str,
choices=ALL_VALID_BROWSER_STRINGS,
help="Browser to use for Udemy Enroller",
Expand Down
9 changes: 1 addition & 8 deletions udemy_enroller/driver_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@
VALID_OPERA_STRINGS = {"opera"}
VALID_EDGE_STRINGS = {"edge"}

ALL_VALID_BROWSER_STRINGS = (
VALID_FIREFOX_STRINGS.union(VALID_CHROME_STRINGS)
.union(VALID_CHROMIUM_STRINGS)
.union(VALID_CHROMIUM_STRINGS)
.union(VALID_INTERNET_EXPLORER_STRINGS)
.union(VALID_OPERA_STRINGS)
.union(VALID_EDGE_STRINGS)
)
ALL_VALID_BROWSER_STRINGS = VALID_CHROME_STRINGS.union(VALID_CHROMIUM_STRINGS)


class DriverManager:
Expand Down
2 changes: 0 additions & 2 deletions udemy_enroller/udemy_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ class UdemyActions:

HEADERS = {
"origin": "https://www.udemy.com",
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 "
"Safari/537.36",
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"content-type": "application/json;charset=UTF-8",
Expand Down
7 changes: 7 additions & 0 deletions udemy_enroller/udemy_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def login(self, is_retry=False) -> None:
"""
if not self.logged_in:
self.driver.get(f"{self.DOMAIN}/join/login-popup/")

# Prompt for email/password if we don't have them saved in settings
if self.settings.email is None:
self.settings.prompt_email()
if self.settings.password is None:
self.settings.prompt_password()

try:
email_element = self.driver.find_element_by_name("email")
email_element.send_keys(self.settings.email)
Expand Down

0 comments on commit ba9f730

Please sign in to comment.