adding reddit downloader
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5m48s

This commit is contained in:
pierre geeraert
2025-12-07 23:22:46 +00:00
parent 98e5ea965c
commit cc8570d02f
3 changed files with 300 additions and 3 deletions
+23 -3
View File
@@ -41,7 +41,8 @@ def form(request):
return render(request, 'stash_form.html',{})
def album(request):
return render(request, 'album_form.html',{})
def simple(request):
return render(request, 'simple_form.html',{})
def check_and_create_destination_folder(name):
#check if the output directory exist and create if not
if not os.path.isdir(destination_folder):
@@ -137,7 +138,20 @@ def individual_image_downloader(image_url, filename ):
print("Still Can't download "+filename+" -- "+image_url+" == Cancelling")
return 0
def simple_form(request):
name = request.GET.get('name')
reddit_downloader(username=name)
text_generated = "successfully sent to the reddit downloader"
return HttpResponse(text_generated, content_type="text/plain")
def reddit_downloader(username):
#create the prerequisites folder
destination_named_folder = check_and_create_destination_folder(name=username)
url = "https://www.reddit.com/user/"+username+"/submitted/.json?limit=1000"
opener = urlrequest.build_opener(proxy)
urlrequest.install_opener(opener)
@@ -145,8 +159,14 @@ def reddit_downloader(username):
req = urlrequest.Request(url)
urlcurl = urlrequest.urlopen(req).read()
data = json.loads(urlcurl)
print(data['data']['children'][0]['data']['url'])
print(data['data']['children'][3]['data']['url'])
picture_list=[]
for children in data['data']['children']:
print("adding to the list : "+children['data']['url'])
picture_list.append(children['data']['url'])
images_downloader.delay(name=username,images_url_list=picture_list,destination_named_folder=destination_named_folder)
return 0
def incremental(request):