diff options
author | gabrielgio <gabriel.giovanini@pm.me> | 2021-07-14 21:47:48 +0200 |
---|---|---|
committer | gabrielgio <gabriel.giovanini@pm.me> | 2021-07-14 21:47:48 +0200 |
commit | 417fb93a9368057e85e4c8bbaabc2ae5aca123d3 (patch) | |
tree | c41889fa5f1d7835d933b4a937ffc43e07344e58 /src/main.py | |
parent | 4d43e402b2b4e27bbbbfe557216d95963a27af72 (diff) | |
download | reddit-nextcloud-importer-417fb93a9368057e85e4c8bbaabc2ae5aca123d3.tar.gz reddit-nextcloud-importer-417fb93a9368057e85e4c8bbaabc2ae5aca123d3.tar.bz2 reddit-nextcloud-importer-417fb93a9368057e85e4c8bbaabc2ae5aca123d3.zip |
fix: Fix pathing
The module imports aren't working.
Diffstat (limited to 'src/main.py')
-rw-r--r-- | src/main.py | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/src/main.py b/src/main.py deleted file mode 100644 index 266bb53..0000000 --- a/src/main.py +++ /dev/null @@ -1,70 +0,0 @@ -import argparse -import os - -import praw -from time import sleep - -from nextcloud import NextCloud -from praw.models.util import stream_generator - -from downloader import Downloader -from uploader import create_folders, upload_file - -parser = argparse.ArgumentParser(description="Monitor saved") -parser.add_argument('-c', '--client-id', - help="Reddit client id", - default=os.environ.get('CLIENT_ID', '')) -parser.add_argument('-s', '--client-secret', - help="Reddit client secret", - default=os.environ.get('CLIENT_SECRET', '')) -parser.add_argument('-u', '--reddit-username', - help="Reddit username", - default=os.environ.get('REDDIT_USERNAME', '')) -parser.add_argument('-p', '--reddit-password', - help="Reddit user password", - default=os.environ.get('REDDIT_PASSWORD', '')) -parser.add_argument('-P', '--nextcloud-password', - help="Nextcloud Password", - default=os.environ.get('NEXTCLOUD_PASSWORD', '')) -parser.add_argument('-U', '--nextcloud-username', - help="Nextcloud Username", - default=os.environ.get('NEXTCLOUD_USERNAME', '')) -parser.add_argument('-o', '--nextcloud-host', - help="Nextcloud Host", - default=os.environ.get('NEXTCLOUD_HOST', 'localhost')) -parser.add_argument('-d', '--nextcloud-path', - help="Nextcloud root folder", - default=os.environ.get('NEXTCLOUD_PATH', 'im')) - -if __name__ == "__main__": - args = parser.parse_args() - reddit = praw.Reddit(client_id=args.client_id, - client_secret=args.client_secret, - password=args.reddit_password, - user_agent="hcrawler", - username=args.reddit_username) - - nxc = NextCloud( - args.nextcloud_host, - user=args.nextcloud_username, - password=args.nextcloud_password, - session_kwargs={'verify': False} - ) - - redditor = reddit.redditor(args.reddit_username) - - - def upload(post): - url = post.url - create_folders(f"{args.nextcloud_path}/{post.subreddit}/", nxc) - with Downloader(url=url, reddit=reddit) as d: - d.download() - for path in d.paths: - if "-mobile" in path: # Remove mobile version - continue - upload_file(path, f"im/{post.subreddit}/{path}", nxc) - - - generator = stream_generator(redditor.saved, attribute_name="name") - for post in generator: - upload(post) |