>>100141998
2nd part of my dogshit code (that chatgpt helped with)
# Download the selected .webm file
index = thumbnails.index(selected_thumbnail)
webm_url = webms[index]
try:
webm_response = requests.get(f'https:{webm_url}', stream=True)
webm_response.raise_for_status()
webm_filename = webm_url.split('/')[-1]
with open(os.path.join('4chanwebms', webm_filename), 'wb') as f:
for chunk in webm_response.iter_content(chunk_size=8192):
f.write(chunk)
print(f"Downloaded {webm_filename} successfully.")
except requests.RequestException as e:
print(f"Failed to download {webm_url}: {e}")
def select_thumbnail(webms, thumbnails):
webm_filenames = [webm.split('/')[-1] for webm in webms]
webm_thumbnails = [thumb for thumb in thumbnails if any(filename in thumb for filename in webm_filenaames)]
thumbnails_str = "\n".join(webm_thumbnails)
fzf_process = subprocess.Popen(['fzf', '--preview-window=right:60%', '--preview', 'ueberzug -r /dev/stdin'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
selected_thumbnail, _ = fzf_process.communicate(input=thumbnails_str.encode())
return selected_thumbnail.decode().strip() if selected_thumbnail else None
if __name__ == '__main__':
thread_url = input("Enter a 4chan thread URL: ")
download_webms(thread_url)