diff options
author | gabrielgio <gabriel.giovanini@pm.me> | 2021-07-14 21:23:44 +0200 |
---|---|---|
committer | gabrielgio <gabriel.giovanini@pm.me> | 2021-07-14 21:23:44 +0200 |
commit | 4d43e402b2b4e27bbbbfe557216d95963a27af72 (patch) | |
tree | 46f3013be10a1062280d64052bcb654d67084f91 /user.py | |
parent | 6887fcc0e42b1a64ed80f8565fe3099aaa818930 (diff) | |
download | reddit-nextcloud-importer-4d43e402b2b4e27bbbbfe557216d95963a27af72.tar.gz reddit-nextcloud-importer-4d43e402b2b4e27bbbbfe557216d95963a27af72.tar.bz2 reddit-nextcloud-importer-4d43e402b2b4e27bbbbfe557216d95963a27af72.zip |
feat: Add nextcloud path param
Add a new param to input the nextcloud root path.
Diffstat (limited to 'user.py')
-rw-r--r-- | user.py | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/user.py b/user.py deleted file mode 100644 index a12cb59..0000000 --- a/user.py +++ /dev/null @@ -1,45 +0,0 @@ -import praw -from time import sleep - -from nextcloud import NextCloud -from praw.models.util import stream_generator - -from download import Downloader -from util import jsonfy, try_post, parser - -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} - ) - - nxc.create_folder(f"im", True) - - redditor = reddit.redditor(args.reddit_username) - - - def uplaod(post): - url = post.url - nxc.create_folder(f"im/{post.subreddit}/", True) - with Downloader(url=url, reddit=reddit) as d: - d.download() - for path in d.paths: - if "-mobile" in path: # Remove mobile version - continue - nxc.upload_file(path, f"im/{post.subreddit}/{path}") - - - sleep(60) - - generator = stream_generator(redditor.saved, attribute_name="name") - for post in generator: - uplaod(post) |