Skip to content

Commit

Permalink
Merge pull request #349 from aapatre/alpha
Browse files Browse the repository at this point in the history
Merging Alpha into develop for release
  • Loading branch information
cullzie authored Nov 12, 2021
2 parents 8b2b8f6 + a8e34f8 commit 9489062
Show file tree
Hide file tree
Showing 13 changed files with 734 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ jobs:
UDEMY_PASSWORD: ${{ secrets.UDEMY_PASSWORD }}
CI_TEST: "True"
run: |
poetry run python udemy_enroller.py --debug
poetry run python udemy_enroller.py --browser=chrome --debug
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ 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.0.0] - 2021-11-12

### Added
- Added support for browser enrolment
- New coupon source from freebiesglobal

### Removed
- Remove REST based enrolment since it is no longer working

## [3.2.0] - 2021-09-13

### Added
Expand Down Expand Up @@ -89,7 +98,9 @@ can continue as normal
zip, extract, install the requirement and get a working version of this
project running locally. Suitable for users who are not looking forward to
contribute.


[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]:
https://github.com/aapatre/Automatic-Udemy-Course-Enroller-GET-PAID-UDEMY-COURSES-for-FREE/releases/tag/v3.2.0
[3.1.0]:
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Props to Davidd Sargent for making a super simple video tutorial. If you prefer
2 . The script can be passed arguments:

- `--help`: View full list of arguments available
- `--browser=<BROWSER_NAME>`: Run with a specific browser
- `--discudemy`: Run the discudemy scraper only
- `--coursevania`: Run the coursevania scraper only
- `--tutorialbar`: Run the tutorialbar scraper only
Expand All @@ -92,9 +93,11 @@ Props to Davidd Sargent for making a super simple video tutorial. If you prefer
- `--debug`: Enable debug logging


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

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

4 . The bot starts scraping the course links from the first **All Courses** page
on [Tutorial Bar](https://www.tutorialbar.com/all-courses/page/1), [DiscUdemy](https://www.discudemy.com/all), [Coursevania](https://coursevania.com) and [FreebiesGlobal](https://freebiesglobal.com) and starts
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
[tool.poetry]
name = "automatic-udemy-course-enroller-get-paid-udemy-courses-for-free"
version = "3.2.0"
version = "4.0.0"
description = ""
authors = [""]

[tool.poetry.dependencies]
python = "^3.8"
selenium = "^3.141.0"
beautifulsoup4 = "^4.9.3"
"ruamel.yaml" = "^0.16.12"
cloudscraper = "^1.2.56"
requests = "^2.25.1"
webdriver-manager = "^3.2.2"
aiohttp = {extras = ["speedups"], version = "^3.7.3"}
price-parser = "^0.3.4"

[tool.poetry.dev-dependencies]
black = "^20.8b1"
Expand All @@ -25,7 +28,7 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.bumpver]
current_version = "3.2.0"
current_version = "4.0.0"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "Bump version {old_version} -> {new_version}"
commit = true
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ beautifulsoup4
ruamel.yaml
requests
cloudscraper
webdriver-manager
selenium
price-parser
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="3.2.0",
version="4.0.0",
long_description=long_description,
long_description_content_type="text/markdown",
author="aapatre",
Expand Down
120 changes: 120 additions & 0 deletions tests/core/test_driver_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
from unittest import mock

import pytest

from udemy_enroller import DriverManager
from udemy_enroller.driver_manager import (
ALL_VALID_BROWSER_STRINGS,
VALID_EDGE_STRINGS,
VALID_FIREFOX_STRINGS,
VALID_INTERNET_EXPLORER_STRINGS,
VALID_OPERA_STRINGS,
)


@pytest.mark.parametrize(
"browser_name",
[
("chrome"),
("chromium"),
("edge"),
("firefox"),
("opera"),
("internet_explorer"),
("tor"),
],
ids=(
"create driver chrome",
"create driver chromium",
"create driver edge",
"create driver firefox",
"create driver opera",
"create driver internet_explorer",
"unsupported browser",
),
)
@mock.patch("udemy_enroller.driver_manager.webdriver")
@mock.patch("udemy_enroller.driver_manager.ChromeDriverManager")
@mock.patch("udemy_enroller.driver_manager.GeckoDriverManager")
@mock.patch("udemy_enroller.driver_manager.EdgeChromiumDriverManager")
@mock.patch("udemy_enroller.driver_manager.IEDriverManager")
@mock.patch("udemy_enroller.driver_manager.OperaDriverManager")
@mock.patch("udemy_enroller.driver_manager.ChromeType")
def test_driver_manager_init(
_,
mock_opera_driver_manager,
mock_internet_explorer_driver_manager,
mock_edge_driver_manager,
mock_firefox_driver_manager,
mock_chrome_driver_manager,
mock_selenium_web_driver,
browser_name,
):
try:
dm = DriverManager(browser_name)
except ValueError:
assert browser_name not in ALL_VALID_BROWSER_STRINGS
else:
if browser_name in ("chrome",):
mock_selenium_web_driver.Chrome.assert_called_once_with(
mock_chrome_driver_manager().install(), options=None
)
assert dm.driver == mock_selenium_web_driver.Chrome()
elif browser_name in ("chromium",):
mock_selenium_web_driver.Chrome.assert_called_once_with(
mock_chrome_driver_manager().install()
)
assert dm.driver == mock_selenium_web_driver.Chrome()
elif browser_name in VALID_FIREFOX_STRINGS:
mock_selenium_web_driver.Firefox.assert_called_once_with(
executable_path=mock_firefox_driver_manager().install()
)
assert dm.driver == mock_selenium_web_driver.Firefox()
elif browser_name in VALID_OPERA_STRINGS:
mock_selenium_web_driver.Opera.assert_called_once_with(
executable_path=mock_opera_driver_manager().install()
)
assert dm.driver == mock_selenium_web_driver.Opera()
elif browser_name in VALID_EDGE_STRINGS:
mock_selenium_web_driver.Edge.assert_called_once_with(
mock_edge_driver_manager().install()
)
assert dm.driver == mock_selenium_web_driver.Edge()
elif browser_name in VALID_INTERNET_EXPLORER_STRINGS:
mock_selenium_web_driver.Ie.assert_called_once_with(
mock_internet_explorer_driver_manager().install()
)
assert dm.driver == mock_selenium_web_driver.Ie()


@pytest.mark.parametrize(
"browser_name,is_ci_build",
[
("chrome", True),
("chrome", False),
],
ids=("chrome is ci build", "chrome is not ci build"),
)
@mock.patch("udemy_enroller.driver_manager.webdriver")
@mock.patch("udemy_enroller.driver_manager.ChromeOptions")
@mock.patch("udemy_enroller.driver_manager.ChromeDriverManager")
@mock.patch("udemy_enroller.driver_manager.ChromeType")
def test_driver_manager_ci_build(
_,
mock_chrome_driver_manager,
mock_chrome_options,
mock_selenium_web_driver,
browser_name,
is_ci_build,
):

dm = DriverManager(browser_name, is_ci_build=is_ci_build)

if is_ci_build:
options = mock_chrome_options()
else:
options = None
mock_selenium_web_driver.Chrome.assert_called_once_with(
mock_chrome_driver_manager().install(), options=options
)
assert dm.driver == mock_selenium_web_driver.Chrome()
4 changes: 3 additions & 1 deletion udemy_enroller/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from .driver_manager import ALL_VALID_BROWSER_STRINGS, DriverManager
from .logging import load_logging_config
from .scrapers.manager import ScraperManager
from .settings import Settings
from .udemy import UdemyActions, UdemyStatus
from .udemy_rest import UdemyActions, UdemyStatus
from .udemy_ui import UdemyActionsUI

load_logging_config()
21 changes: 17 additions & 4 deletions udemy_enroller/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from argparse import Namespace
from typing import Tuple, Union

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

logger = get_logger()

Expand Down Expand Up @@ -56,6 +56,7 @@ def determine_if_scraper_enabled(


def run(
browser: str,
freebiesglobal_enabled: bool,
tutorialbar_enabled: bool,
discudemy_enabled: bool,
Expand All @@ -66,6 +67,8 @@ def run(
):
"""
Run the udemy enroller script
:param str browser: Name of the browser we want to create a driver for
:param bool freebiesglobal_enabled:
:param bool tutorialbar_enabled:
:param bool discudemy_enabled:
Expand All @@ -76,7 +79,10 @@ def run(
:return:
"""
settings = Settings(delete_settings, delete_cookie)
redeem_courses(

dm = DriverManager(browser=browser, is_ci_build=settings.is_ci_build)
redeem_courses_ui(
dm.driver,
settings,
freebiesglobal_enabled,
tutorialbar_enabled,
Expand All @@ -94,13 +100,19 @@ def parse_args() -> Namespace:
"""
parser = argparse.ArgumentParser(description="Udemy Enroller")

parser.add_argument(
"--browser",
required=True,
type=str,
choices=ALL_VALID_BROWSER_STRINGS,
help="Browser to use for Udemy Enroller",
)
parser.add_argument(
"--freebiesglobal",
action="store_true",
default=False,
help="Run freebiesglobal scraper",
)

parser.add_argument(
"--tutorialbar",
action="store_true",
Expand Down Expand Up @@ -168,6 +180,7 @@ def main():
args.freebiesglobal, args.tutorialbar, args.discudemy, args.coursevania
)
run(
args.browser,
freebiesglobal_enabled,
tutorialbar_enabled,
discudemy_enabled,
Expand Down
Loading

0 comments on commit 9489062

Please sign in to comment.