Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About to significantly update the "next" branch... #19

Open
wants to merge 10 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
language: "python"
python: "3.6"
install:
- pip install requests pyyaml pytest-cov python-coveralls
- pip install requests pyyaml pytest-cov python-coveralls httpretty codacy-coverage
script:
- python3 -m pytest --cov=.
after_success:
- coveralls
- coverage xml
- python-codacy-coverage -r coverage.xml
notifications:
- email: false
55 changes: 7 additions & 48 deletions hb-downloader.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logger
from config_data import ConfigData
from configuration import Configuration
from event_handler import EventHandler
from humble_api.humble_api import HumbleApi
from actions import Action

__author__ = "Brian Schkerke"
__copyright__ = "Copyright 2016 Brian Schkerke"
__license__ = "MIT"


print("Humble Bundle Downloader v%s" % ConfigData.VERSION)
print("This program is not affiliated nor endorsed by Humble Bundle, Inc.")
print("For any suggestion or bug report, please create an issue at:\n%s" %
ConfigData.BUG_REPORT_URL)
print("")

# Load the configuration from the YAML file...
Configuration.load_configuration("hb-downloader-settings.yaml")
Configuration.parse_command_line()
Configuration.dump_configuration()
Configuration.push_configuration()

validation_status, message = Configuration.validate_configuration()
if not validation_status:
logger.display_message(False, "Error", message)
exit("Invalid configuration. Please check your command line arguments and"
"hb-downloader-settings.yaml.")

# Initialize the event handlers.
EventHandler.initialize()

hapi = HumbleApi(ConfigData.auth_sess_cookie)

if not hapi.check_login():
exit("Login to humblebundle.com failed."
" Please verify your authentication cookie")

logger.display_message(False, "Processing", "Downloading order list.")
game_keys = hapi.get_gamekeys()
logger.display_message(False, "Processing", "%s orders found." %
(len(game_keys)))

if ConfigData.action == "download":
Action.batch_download(hapi, game_keys)
else:
Action.list_downloads(hapi, game_keys)
import sys
import humble_downloader

__author__ = "Mayeul Cantan"
__copyright__ = "Copyright 2018 Mayeul Cantan"
__license__ = "MIT"

exit()
if __name__ == "__main__":
sys.exit(humble_downloader.main())
10 changes: 0 additions & 10 deletions humble_api/exceptions/__init__.py

This file was deleted.

59 changes: 59 additions & 0 deletions humble_downloader/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import humble_downloader.logger as logger
from humble_downloader.config_data import ConfigData
from .configuration import Configuration
from .event_handler import EventHandler
from .humble_api.humble_api import HumbleApi
from .actions import Action

__author__ = "Brian Schkerke"
__copyright__ = "Copyright 2016 Brian Schkerke"
__license__ = "MIT"

__all__ = ["ConfigData", "Action", "display_message", "HumbleDownload", "ProgressTracker"]


def main():
print("Humble Bundle Downloader v%s" % ConfigData.VERSION)
print("This program is not affiliated nor endorsed by Humble Bundle, Inc.")
print("For any suggestion or bug report, please create an issue at:\n%s" %
ConfigData.BUG_REPORT_URL)
print("")

# Load the configuration from the YAML file...
Configuration.load_configuration("hb-downloader-settings.yaml")
Configuration.parse_command_line()
Configuration.dump_configuration()
Configuration.push_configuration()

validation_status, message = Configuration.validate_configuration()
if not validation_status:
logger.display_message(False, "Error", message)
sys.exit("Invalid configuration. Please check your command line "
"arguments and hb-downloader-settings.yaml.")

# Initialize the event handlers.
EventHandler.initialize()

hapi = HumbleApi(ConfigData.auth_sess_cookie)

if not hapi.check_login():
exit("Login to humblebundle.com failed."
" Please verify your authentication cookie")

logger.display_message(False, "Processing", "Downloading order list.")
game_keys = hapi.get_gamekeys()
logger.display_message(False, "Processing", "%s orders found." %
(len(game_keys)))

if ConfigData.action == "download":
Action.batch_download(hapi, game_keys)
else:
Action.list_downloads(hapi, game_keys)


if __name__ == "__main__":
sys.exit(main())
11 changes: 7 additions & 4 deletions actions.py → humble_downloader/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@

__license__ = "MIT"

from humble_download import HumbleDownload
from progress_tracker import ProgressTracker
from config_data import ConfigData
import logger
from .humble_download import HumbleDownload
from .progress_tracker import ProgressTracker
from .config_data import ConfigData
from . import logger


class Action:
@staticmethod
def list_downloads(hapi, game_keys):
for key in game_keys:
if ConfigData.download_platforms.get("humble-keys", False):
print("%s" % key)
continue
selector_matched_key_once = False
current_order = hapi.get_order(key)

Expand Down
File renamed without changes.
21 changes: 15 additions & 6 deletions configuration.py → humble_downloader/configuration.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
import os
import yaml
import logger
from config_data import ConfigData
from humble_api.humble_hash import HumbleHash
from . import logger
from .config_data import ConfigData
from .humble_api.humble_hash import HumbleHash

__author__ = "Brian Schkerke"
__copyright__ = "Copyright 2016 Brian Schkerke"
Expand Down Expand Up @@ -114,12 +115,16 @@ def parse_command_line():

for action in [a_list, a_download]:
item_type = action.add_subparsers(title="type", dest="item_type")
games = item_type.add_parser("games")
games = item_type.add_parser("games", help="Only list games")
games.add_argument(
"--platform", nargs='+', choices=[ # TODO: add NATIVE?
"linux", "mac", "windows", "android", "asmjs"])
item_type.add_parser("ebooks")
item_type.add_parser("audio")
item_type.add_parser("ebooks", help="Only list ebooks")
item_type.add_parser("audio", help="Only display audio products")
if action is a_list:
item_type.add_parser("humble-keys", help=(
"Only list humble bundle keys that identify each "
"purchase"))

a_list.add_argument(
"-u", "--print-url", action="store_true", dest="print_url",
Expand Down Expand Up @@ -154,6 +159,10 @@ def configure_action(args):
ConfigData.download_platforms[platform] = True
else:
ConfigData.download_platforms[platform] = False
# "fake platforms" can be defined to list info like humble keys
# TODO: only allow them for listing?
if args.item_type not in ConfigData.download_platforms:
ConfigData.download_platforms[args.item_type] = True
else:
args.action = "download"
ConfigData.action = args.action
Expand Down
5 changes: 3 additions & 2 deletions event_handler.py → humble_downloader/event_handler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import logger
from humble_api.events import Events
from . import logger
from .humble_api.events import Events

__author__ = "Brian Schkerke"
__copyright__ = "Copyright 2016 Brian Schkerke"
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions humble_downloader/humble_api/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "Joel Pedraza"
__copyright__ = "Copyright 2014, Joel Pedraza"
__license__ = "MIT"

__all__ = ["HumbleAuthenticationException", "HumbleDownloadNeededException", "HumbleException", "HumbleParseException",
"HumbleResponseException"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions humble_download.py → humble_downloader/humble_download.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import requests
from config_data import ConfigData
from humble_api.events import Events
from humble_api.humble_hash import HumbleHash
from .config_data import ConfigData
from .humble_api.events import Events
from .humble_api.humble_hash import HumbleHash

__author__ = "Brian Schkerke"
__copyright__ = "Copyright 2016 Brian Schkerke"
Expand Down
3 changes: 2 additions & 1 deletion logger.py → humble_downloader/logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from config_data import ConfigData

from .config_data import ConfigData
import time
import sys

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logger

__author__ = "Brian Schkerke"
__copyright__ = "Copyright 2016 Brian Schkerke"
__license__ = "MIT"

from . import logger


class ProgressTracker(object):
item_count_current = 0
Expand Down
36 changes: 36 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-


import os
from setuptools import setup, find_packages


def read(file_name):
return open(os.path.join(os.path.dirname(__file__), file_name)).read()

setup(
name="humble_downloader", # your package name (i.e. for import)
version="0.5.0",
maintainer="Mayeul Cantan",
maintainer_email="mayeul.cantan@live.fr",
author="Brian Schkerke, Mayeul Cantan",
author_email="N/A, mayeul.cantan@live.fr",
description="An automated utility to download your Humble Bundle purchases.",
license="MIT",
keywords="humble bundle download games",
url="https://github.com/MayeulC/hb-downloader",
packages=find_packages(exclude=["*test*", "*TEST*"]),
install_requires=[
'requests',
'pyyaml',
],
long_description=read('README.md'),
classifiers=[
"Development Status :: 4 - Beta",
"Topic :: Utilities",
"License :: OSI Approved :: MIT",
"Natural Language :: English"
],
zip_safe=True,
)
Loading