From 0229f63df29a27cf7f7648fff3a1a7a741fccf9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Wed, 6 Jul 2022 14:32:34 +0200 Subject: [PATCH] added nfws restriction and changed some shit in the ps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- meme-of-the-day-client.ps1 | 10 ++++------ save-image.py | 15 ++++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/meme-of-the-day-client.ps1 b/meme-of-the-day-client.ps1 index 4b4b5a7..0d0dcac 100644 --- a/meme-of-the-day-client.ps1 +++ b/meme-of-the-day-client.ps1 @@ -1,10 +1,8 @@ Function Set-WallPaper($Value){ - $url = "https://motd.ping-mee.de/wallpaper.png"; - $wc = New-Object System.Net.WebClient - $wc.DownloadFile($url, "C:\temp\wallpaper.png") - Invoke-WebRequest $url -OutFile C:\temp\wallpaper.png - Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value + Invoke-WebRequest "https://motd.ping-mee.de/wallpaper.png" -OutFile "$($value)wallpaper.png" + Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value "$($value)wallpaper.png" rundll32.exe user32.dll, UpdatePerUserSystemParameters + } -Set-WallPaper -value "C:\temp\wallpaper.png" \ No newline at end of file +Set-WallPaper -value "C:\temp\" \ No newline at end of file diff --git a/save-image.py b/save-image.py index 4641993..431f1e9 100644 --- a/save-image.py +++ b/save-image.py @@ -27,13 +27,14 @@ subreddit = reddit.subreddit(subreddit_name) posts = subreddit.top(time_filter="day", limit=5) for post in posts: try: - print(post.url) - if post.url.endswith(".png") or post.url.endswith(".jpg"): - debugging_message("Found a new post: "+post.title+" ("+post.id+")") + if post.over_18 == False: print(post.url) - debugging_message("Saving post to file") - with open(current_path+'/wallpaper.png', "wb") as file: - file.write(requests.get(post.url).content) - debugging_message("Saving post to file done") + if post.url.endswith(".png") or post.url.endswith(".jpg"): + debugging_message("Found a new post: "+post.title+" ("+post.id+")") + print(post.url) + debugging_message("Saving post to file") + with open(current_path+'/wallpaper.png', "wb") as file: + file.write(requests.get(post.url).content) + debugging_message("Saving post to file done") except: debugging_message("Error while getting post skipping and continuing") \ No newline at end of file