From 61232b80ba22b4ae565b8683d261d5efd23bfd99 Mon Sep 17 00:00:00 2001 From: tauqua Date: Tue, 8 Sep 2020 14:39:30 -0500 Subject: [PATCH] Add changes with fixed line endings --- .gitignore | 5 +++++ claim_itch.py | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b6e4761..97eaa90 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,8 @@ dmypy.json # Pyre type checker .pyre/ + +# Run artifacts +*.log.txt +geckodriver.exe +*.history.json diff --git a/claim_itch.py b/claim_itch.py index 3883044..fef4516 100644 --- a/claim_itch.py +++ b/claim_itch.py @@ -119,7 +119,11 @@ def extract_from_itch_group(group_page): OUTPUT urls of all games, urls of games that avie noted is connected to more sales ''' soup = BeautifulSoup(group_page, 'lxml') + ended = soup.find_all('div', class_ = 'not_active_notification') urls, more = set(), set() + if ended: + print(" Sale ended") + return urls, more games = soup.find_all('div', class_='game_cell') for game in games: url = game.find('a').get('href') @@ -342,10 +346,12 @@ def claim(url, driver): raise ParsingError(url) -def create_driver(enable_images=False): +def create_driver(enable_images=False, mute=False): options = webdriver.firefox.options.Options() if not enable_images: options.set_preference('permissions.default.image', 2) + if mute: + options.set_preference('media.volume_scale', '0.0') if os.path.exists('geckodriver.exe'): driver = webdriver.Firefox(options=options, executable_path='geckodriver.exe') else: @@ -479,6 +485,7 @@ def main(): arg_parser.add_argument('--recheck', action='store_true', help='reload game links from SOURCES') arg_parser.add_argument('--recheck-groups', action='store_true', help='reload game links from discovered itch collections / sales') arg_parser.add_argument('--enable-images', action='store_true', help='load images in the browser while claiming games') + arg_parser.add_argument('--mute', action='store_true', help='automatically mute while claiming games') arg_parser.add_argument('--ignore', action='store_true', help='continue even if an error occurs when handling a game') args = arg_parser.parse_args() @@ -530,8 +537,7 @@ def main(): ignore = set().union(*map(history.get, PROCESSED_GAMES)) valid = history['urls'].difference(ignore) if len(valid) > 0: - with create_driver(args.enable_images) as driver: - driver.get('https://itch.io/login') + with create_driver(args.enable_images, args.mute) as driver: # manually log in input('A new Firefox window was opened. Log in to itch then click enter to continue') for i, url in enumerate(valid):