Skip to content

Instantly share code, notes, and snippets.

@rakisaionji
Forked from lyricalpaws/fuck.py
Last active September 25, 2024 21:49
Show Gist options
  • Save rakisaionji/5c06dfec27b5699c25ae663e29980875 to your computer and use it in GitHub Desktop.
Save rakisaionji/5c06dfec27b5699c25ae663e29980875 to your computer and use it in GitHub Desktop.
Grabs all of Marques Brownlee's shitty scam app (panels.art)'s wallpapers, with date keeping (also Python is fucking retarded)
import requests
import os
import time
from urllib.parse import urlparse
from datetime import datetime
DATE_PATTERN = "%a, %d %b %Y %H:%M:%S %Z"
def downloadImage(url, filePath):
try:
response = requests.get(url)
if response.status_code == 200:
with open(filePath, 'wb') as f:
f.write(response.content)
fileDate = response.headers['Last-Modified']
timestamp = int(datetime.strptime(fileDate, DATE_PATTERN).timestamp())
os.utime(filePath, (timestamp, timestamp))
else:
print(f"Failed to download image: {response.status_code}")
except Exception as e:
print(f"Error: {e}")
def main():
print("""\
.__ .__ .__
| | ___.__._______|__| ____ _____ | | ___________ __ _ ________
| |< | |\_ __ \ |/ ___\\__ \ | | \____ \__ \\ \/ \/ / ___/
| |_\___ | | | \/ \ \___ / __ \| |_| |_> > __ \\ /\___ \
|____/ ____| |__| |__|\___ >____ /____/ __(____ /\/\_//____ >
\/ \/ \/ |__| \/ \/
""")
url = "https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s"
try:
response = requests.request("GET", url)
downloadDir = f"{os.getcwd()}/download"
if os.path.exists(downloadDir) is False:
os.mkdir(downloadDir)
print("Download folder does not exist! Making one!")
jsonData = response.json()
data = jsonData.get('data')
fileIndex = 1
for key in data:
subProperty = data[key]
if subProperty and 'dhd' in subProperty:
imageUrl = subProperty['dhd']
print("🔍 Found image URL!")
time.sleep(1)
ext = os.path.splitext(urlparse(imageUrl).path)[1] or '.jpg'
fileName = f"{fileIndex}{ext}"
filePath = os.path.join(downloadDir, fileName)
downloadImage(imageUrl, filePath)
print(f"🖼️ Saved image to {filePath}")
fileIndex += 1
except requests.exceptions.RequestException as e:
print(e)
if __name__ =="__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment