George Kalamaras

All generations.

generate functionTue, 29 Nov 2022

Delete any files and folders that are older than 14 days in "E:\usenet\tv\" and "E:\usenet\movies\".

import os import time def delete_older(path, base, days): now = time.time() cutoff = now - (days * 86400) for dirName, subdirList, fileList in os.walk(path): for f in fileList: fp = os.path.join(dirName, f) if os.stat(fp).st_mtime < cutoff: if os.path.isfile(fp): os.unlink(fp) else: shutil.rmtree(fp, ignore_errors=True) delete_older("E:\usenet\tv\\", 14) delete_older("E:\usenet\movies\\", 14)

Python
View
fix invalid codeThu, 12 Jan 2023

import os import subprocess from send2trash import send2trash import time def convert_to_16bit_44khz(filepath): filename = os.path.basename(filepath) wav_file_name = os.path.splitext(filename)[0] + ".wav" new_file_name = os.path.splitext(filename)[0] + "-converted.flac" try: output = subprocess.run(["flac", "-d", filepath], capture_output=True, text=True) if "ERROR" in output.stderr: print("An error occurred: " + output.stderr) else: subprocess.run(["sox", wav_file_name, "-b", "16", "-r", "44100", "-e", "signed", wav_file_name]) subprocess.run(["flac", wav_file_name, "-f", "--delete-input-file"]) os.rename(wav_file_name + ".flac", new_file_name) print(f"Converted {filename} to {new_file_name}") send2trash(filepath) except: print("An error occurred while converting " + filename) time.sleep(15) for subdir, dirs, files in os.walk("d:\\lidarr"): for file in files: if file.endswith(".flac"): filepath = subdir + os.sep + file convert_to_16bit_44khz(filepath)

Fix invalid code:

fix invalid codeThu, 12 Jan 2023

import os import subprocess from send2trash import send2trash import time def convert_to_16bit_44khz(filepath): filename = os.path.basename(filepath) wav_file_name = os.path.splitext(filename)[0] + ".wav" new_file_name = os.path.splitext(filename)[0] + "-converted.flac" try: output = subprocess.run(["flac", "-d", filepath], capture_output=True, text=True) if "ERROR" in output.stderr: print("An error occurred: " + output.stderr) else: subprocess.run(["sox", wav_file_name, "-b", "16", "-r", "44100", "-e", "signed", wav_file_name]) subprocess.run(["flac", wav_file_name, "-f", "--delete-input-file"]) os.rename(wav_file_name + ".flac", new_file_name) print(f"Converted {filename} to {new_file_name}") send2trash(filepath) except: print("An error occurred while converting " + filename) time.sleep(15) for subdir, dirs, files in os.walk("d:\\lidarr"): for file in files: if file.endswith(".flac"): filepath = subdir + os.sep + file convert_to_16bit_44khz(filepath)

generate functionTue, 29 Nov 2022

Delete files and folders older than 14 days in "E:\usenet\tv\" and in "E:\usenet\movies\".

import os import time #target = 'E:\usenet\tv\\' target = 'E:\usenet\movies\\' now = time.time() for root, dirs, files in os.walk(target): for f in files: path_file = os.path.join(root, f) if os.stat(path_file).st_mtime < now - 14 * 86400: if os.path.isfile(path_file): os.remove(path_file) for d in dirs: path_dir = os.path.join(root, d) if os.stat(path_dir).st_mtime < now - 14 * 86400: if os.path.isdir(path_dir): os.rmdir(path_dir)

Python
View
generate functionSun, 13 Nov 2022

Combine two of these randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Send the result to discord via webhook.

import random from webhooks import Webhook def add(a, b): return a + b def send_to_discord(data): hook = Webhook('webhook') hook.post(data) bottles = ['MINT', 'ORANGE', 'COCONUT', 'BLUEBERRY', 'PEACH', 'CHERRY', 'BERRY', 'GRAPE', 'GUAVA', 'GRAPEFRUIT', 'MANGO', 'LEMON', 'GRENADINE', 'STRAWBERRY', 'KIWI', 'MELON', 'HONEY', 'VANILLA', 'WATERMELON', 'APPLE', 'PLUM', 'PINEAPPLE', 'CAPPUCCINO', 'ROSE'] send_to_discord(random.choice(bottles) + ' ' + random.choice(bottles))

Python
View
generate functionSun, 13 Nov 2022

Combine two of these flavours randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Save the result to a text file at D:\Flavour.txt. Send D:\Flavour.txt via discord webhook.

import random flavours = ['MINT', 'ORANGE', 'COCONUT', 'BLUEBERRY', 'PEACH', 'CHERRY', 'BERRY', 'GRAPE', 'GUAVA', 'GRAPEFRUIT', 'MANGO', 'LEMON', 'GRENADINE', 'STRAWBERRY', 'KIWI', 'MELON', 'HONEY', 'VANILLA', 'WATERMELON', 'APPLE', 'PLUM', 'PINEAPPLE', 'CAPPUCCINO', 'ROSE'] file = open("D:\Flavour.txt", "w") file.write(random.choice(flavours) + random.choice(flavours)) file.close()

Python
View
generate functionSun, 13 Nov 2022

Combine two of these randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Send the result to discord via webhook.

import requests import random flavours = [ 'MINT', 'ORANGE', 'COCONUT', 'BLUEBERRY', 'PEACH', 'CHERRY', 'BERRY', 'GRAPE', 'GUAVA', 'GRAPEFRUIT', 'MANGO', 'LEMON', 'GRENADINE', 'STRAWBERRY', 'KIWI', 'MELON', 'HONEY', 'VANILLA', 'WATERMELON', 'APPLE', 'PLUM', 'PINEAPPLE', 'CAPPUCCINO', 'ROSE' ] def combine_flavor(): return random.choice(flavours) + random.choice(flavours) combine_flavor()

Python
View
generate functionSun, 13 Nov 2022

Combine these randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Output the file as "flavour one" plus "flavour two".

import random as r def icecream_combine(flavours): fl = r.sample(flavours, 2) return fl[0] + " " + fl[1] flavours = ["MINT", "ORANGE", "COCONUT", "BLUEBERRY", "PEACH", "CHERRY", "BERRY", "GRAPE", "GUAVA", "GRAPEFRUIT", "MANGO", "LEMON", "GRENADINE", "STRAWBERRY", "KIWI", "MELON", "HONEY", "VANILLA", "WATERMELON", "APPLE", "PLUM", "PINEAPPLE", "CAPPUCCINO", "ROSE"] print(icecream_combine(flavours))

Python
View
generate functionTue, 29 Nov 2022

Delete files and folders that are older than 14 days in "E:\usenet\tv\". Delete files and folders that are older than 14 days in "E:\usenet\movies\".

import time import os from os.path import join def delete_old_files(folder, days=14): folders = [join(folder, f) for f in os.listdir(folder) if os.path.isdir(join(folder, f))] for f in folders: if os.path.getctime(f) < time.time() - days * 86400: os.remove(f) delete_old_files('E:\usenet\tv') delete_old_files('E:\usenet\movies')

Python
View
generate functionSat, 12 Nov 2022

Check if the program "qbe-instance1.exe" is running, if not, launch it in 30 seconds.

from time import sleep import os import psutil def check_qbe_running(qbe_exe_path): qbe_proc = "qbe-instance1.exe" if not qbe_exe_path.endswith('/'): qbe_exe_path += '/' qbe_exe = os.path.join(qbe_exe_path, qbe_proc) for proc in psutil.process_iter(): if proc.name() == qbe_proc: return True print "QBE not running, wait for 30 seconds and launch QBE." sleep(30) os.system(qbe_exe) return False

Python
View
generate functionMon, 14 Nov 2022

Combine two of these flavors randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Create a text file with the results as randomhookah.txt.

import random flavors = ["MINT", "ORANGE", "COCONUT", "BLUEBERRY", "PEACH", "CHERRY", "BERRY", "GRAPE", "GUAVA", "GRAPEFRUIT", "MANGO", "LEMON", "GRENADINE", "STRAWBERRY", "KIWI", "MELON", "HONEY", "VANILLA", "WATERMELON", "APPLE", "PLUM", "PINEAPPLE", "CAPPUCCINO", "ROSE"] def randomHookah(): return random.choice(flavors) + " + " + random.choice(flavors) with open("randomhookah.txt", "w") as f: f.write(randomHookah())

Python
View
generate functionTue, 29 Nov 2022

Delete files and folders older than 14 days in "E:\usenet\tv\"

import os import time import shutil now = time.time() # Delete files and folders older than 14 days in "E:\usenet\tv\" os.remove(r'E:\usenet\tv\*.*') # Delete files and folders older than 14 days in "E:\usenet\tv\" os.rmdir(r'E:\usenet\tv\*.*') # Delete files and folders older than 14 days in "E:\usenet\tv\" shutil.rmtree(r'E:\usenet\tv\*.*')

Python
View
fix invalid codeThu, 12 Jan 2023

import os import subprocess from send2trash import send2trash import time def convert_to_16bit_44khz(filepath): filename = os.path.basename(filepath) wav_file_name = os.path.splitext(filename)[0] + ".wav" new_file_name = os.path.splitext(filename)[0] + "-converted.flac" try: output = subprocess.run(["flac", "-d", filepath], capture_output=True, text=True) if "ERROR" in output.stderr: print("An error occurred: " + output.stderr) else: subprocess.run(["sox", wav_file_name, "-b", "16", "-r", "44100", "-e", "signed", wav_file_name]) subprocess.run(["flac", wav_file_name, "-f", "--delete-input-file"]) os.rename(wav_file_name + ".flac", new_file_name) print(f"Converted {filename} to {new_file_name}") send2trash(filepath) except: print("An error occurred while converting " + filename) time.sleep(15) for subdir, dirs, files in os.walk("d:\\lidarr"): for file in files: if file.endswith(".flac"): filepath = subdir + os.sep + file convert_to_16bit_44khz(filepath)

## Usage

generate functionTue, 29 Nov 2022

Delete files and folders that are older than 14 days in "E:\usenet\tv\". Delete files and folders that are older than 14 days in "E:\usenet\movies\".

from datetime import datetime, timedelta import os def delete_old_files(path): now = datetime.now() for f in os.listdir(path): f = os.path.join(path, f) if os.stat(f).st_mtime < now.timestamp() - 14 * 86400: if os.path.isfile(f): os.remove(f) else: os.removedirs(f) delete_old_files("E:\usenet\tv\") delete_old_files("E:\usenet\movies\"

Python
View
generate functionMon, 14 Nov 2022

Combine two of these randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Send the text result to discord via webhook.

import random import requests def getFlavor(): flavors = [ "MINT", "ORANGE", "COCONUT", "BLUEBERRY", "PEACH", "CHERRY", "BERRY", "GRAPE", "GUAVA", "GRAPEFRUIT", "MANGO", "LEMON", "GRENADINE", "STRAWBERRY", "KIWI", "MELON", "HONEY", "VANILLA", "WATERMELON", "APPLE", "PLUM", "PINEAPPLE", "CAPPUCCINO", "ROSE" ] return random.choice(flavors) def getFlavors(): flavor1 = getFlavor() flavor2 = getFlavor()

Python
View
code to explanationThu, 12 Jan 2023

import os import subprocess from send2trash import send2trash import time def convert_to_16bit_44khz(filepath): filename = os.path.basename(filepath) wav_file_name = os.path.splitext(filename)[0] + ".wav" new_file_name = os.path.splitext(filename)[0] + "-converted.flac" try: output = subprocess.run(["flac", "-d", filepath], capture_output=True, text=True) if "ERROR" in output.stderr: print("An error occurred: " + output.stderr) else: subprocess.run(["sox", wav_file_name, "-b", "16", "-r", "44100", "-e", "signed", wav_file_name]) subprocess.run(["flac", wav_file_name, "-f", "--delete-input-file"]) os.rename(wav_file_name + ".flac", new_file_name) print(f"Converted {filename} to {new_file_name}") send2trash(filepath) except: print("An error occurred while converting " + filename) time.sleep(15) for subdir, dirs, files in os.walk("d:\\lidarr"): for file in files: if file.endswith(".flac"): filepath = subdir + os.sep + file convert_to_16bit_44khz(filepath)

This script walks through all subdirectories of d:\lidarr and looks for each file ending with .flac. For each of these files it starts the conversion process.

generate functionMon, 14 Nov 2022

Combine two of these randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Send the text result to discord via webhook.

import random import requests def make_drink(): ingredients = ['MINT', 'ORANGE', 'COCONUT', 'BLUEBERRY', 'PEACH', 'CHERRY', 'BERRY', 'GRAPE', 'GUAVA', 'GRAPEFRUIT', 'MANGO', 'LEMON', 'GRENADINE', 'STRAWBERRY', 'KIWI', 'MELON', 'HONEY', 'VANILLA', 'WATERMELON', 'APPLE', 'PLUM', 'PINEAPPLE', 'CAPPUCCINO', 'ROSE'] drink = random.choices(ingredients, k=2) drink = " ".join(drink) return drink def send_to_discord(drink): webhook = 'https://discord.com/api/webhooks/723742767684722698/6YFZ6TmDxnCmJk-lzdgf6P8hXQ2b-_U6TfZgT

Python
View
generate functionSat, 12 Nov 2022

Find files with extension .tdarrcache* on d:/. If the files are over two days old, delete them. Log the files deleted to d:/tdarrremoved.txt.

import os, datetime, time, re def remove_files(path): os.chdir(path) now = datetime.datetime.now() days_ago = now - datetime.timedelta(days=2) days_ago_epoch = time.mktime(days_ago.timetuple()) days_ago_readable = time.ctime(days_ago_epoch) files = os.listdir(path) for f in files: if os.path.isfile(f) and re.match('.*\.tdarrcache.*', f): file_epoch = os.path.getmtime(f) if file_epoch < days_ago_epoch: os.remove(f) with open('d:/tdarrremoved.txt', 'a') as log: log.write('removed ' + f + ' on ' + days_ago_readable + '\n') remove_files('d:/')

Python
View
generate functionMon, 14 Nov 2022

Send randomhookah.txt to a discord webhook.

import random import json import requests #load data with open('randomhookah.txt', 'r') as f: data = f.readlines() def sendhookah(): #pick random line line = random.choice(data) #make it into json json_data = json.dumps(line) #send with requests requests.post('webhook url', data = json_data)

Python
View
generate functionTue, 29 Nov 2022

Delete files and folders that are older than 14 days in directories: "E:\usenet\tv\" and "E:\usenet\movies\".

import os import sys import time deleted = 0 def delete_if_old(path): now = time.time() for f in os.listdir(path): f = os.path.join(path, f) if os.stat(f).st_mtime < now - 14 * 86400: if os.path.isdir(f): # recursively delete directory if not delete_if_old(f): return False else: try: os.remove(f) deleted += 1 except OSError: return False return True delete_if_old("E:\usenet\tv") delete_if_old("E:\usenet\movies")

Python
View
generate functionTue, 29 Nov 2022

Delete files and folders that are older than 14 days in "E:\usenet\tv\". Delete files and folders that are older than 14 days in "E:\usenet\movies\".

import os, time for file in os.listdir('E:\usenet\tv\\'): if os.stat(os.path.join('E:\usenet\tv\\', file)).st_mtime < time.time() - 14 * 86400: if os.path.isdir(os.path.join('E:\usenet\tv\\', file)): shutil.rmtree(os.path.join('E:\usenet\tv\\', file)) else: os.remove(os.path.join('E:\usenet\tv\\', file)) for file in os.listdir('E:\usenet\movies\\'): if os.stat(os.path.join('E:\usenet\movies\\', file)).st_mtime < time.time() - 14 * 86400: if os.path.isdir(os.path.join('E:\usenet\movies\\', file)): shutil.rmtree(os.path.join('

Python
View
generate functionSat, 12 Nov 2022

Find files with extension .tdarrcache* on d:/. If the files are over two days old, delete them. Log the results to d:/tdarrremoved.txt.

import os import time import datetime #create a log file with the time logFileName = "d:/tdarrremoved.txt" with open(logFileName, 'a') as f: f.write("{}".format(datetime.datetime.now())) f.write("\n") d = "d:/" for f in os.listdir(d): if f.endswith(".tdarrcache"): fileTime = os.path.getmtime(d+f) twoDaysAgo = time.time() - (60 * 60 * 24 * 2) if fileTime < twoDaysAgo: os.remove(d+f) with open(logFileName, 'a') as f: f.write("{}".format(f)) f.write("\n")

Python
View
generate functionSat, 12 Nov 2022

Open a new fullscreen window that has the text "butts" written in the center. Wait for 30 seconds, then close the window.

import pygame import time pygame.init() window = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) width, height = pygame.display.get_surface().get_size() text = "butts" font = pygame.font.SysFont("Arial", int(width / 5)) textSurface = font.render(text, True, (255, 255, 255)) rect = textSurface.get_rect() rect.center = (width / 2, height / 2) window.blit(textSurface, rect) pygame.display.update() time.sleep(30) pygame.quit()

Python
View
generate functionSun, 13 Nov 2022

Delete files named *.tdarrcache* in D:\sonarr\ and D:\radarr\ only if they are over 2 days old.

#!/usr/bin/env python3 # Imports import os import datetime as dt # Set directory to search folder = [r'D:\radarr', r'D:\sonarr'] # Set file extension to search for extension = r'*.tdarrcache' # Set age of files to delete age_in_days = 2 def delete_old_files(folder, extension, age_in_days): today = dt.datetime.today() files = [] for root, dirs, filenames in os.walk(folder): for filename in fnmatch.filter(filenames, extension): files.append(os.path.join(root, filename)) for file in files: if (today - dt.datetime.fromtimestamp(os.path.getmtime(file))).days >= age_in_days: os.remove(file) print('Delete: {}'.format(file)) for f in folder: delete_old_files(f, extension

Python
View
generate functionMon, 14 Nov 2022

Send hookah.txt to a discord webhook.

import requests def send_hookah(webhook_url, file_path): """ Sends a file to a discord webhook. """ with open(file_path, 'r') as f: content = f.read() r = requests.post(webhook_url, json={"content":content}) send_hookah('https://discordapp.com/api/webhooks/...', 'hookah.txt')

Python
View
generate functionSat, 12 Nov 2022

Find files with extension .tdarrcache* on d:/. If the files are over two days old, delete them.

import os import datetime now = datetime.datetime.now() def find_and_delete(path,ext,age): for root, dirs, files in os.walk(path): for file in files: fname = os.path.join(root, file) asplit = os.path.splitext(fname) file_ext = asplit[1] file_time = datetime.datetime.fromtimestamp(os.path.getmtime(fname)) if file_ext == ext and (now - file_time).days > age: os.remove(fname) print('file deleted') else: print('file not deleted') find_and_delete('d:/', 'tdarrcache', 2)

Python
View
generate functionSat, 12 Nov 2022

Find files with extension .tdarrcache* on d:/. If the files are over two days old, delete them. Log the results to d:/tdarrremoved.txt.

#!/usr/bin/env python import os import time import datetime import shutil # Set the directory you want to start from rootDir = 'D:\\' # Delete files and log def deleteFile(fileName, filePath): print(fileName + ' deleted') fileToDelete = filePath + fileName os.remove(fileToDelete) with open('D:\\tdarrremoved.txt','a') as f: f.write('\n' + fileName + ' deleted.') for dirName, subdirList, fileList in os.walk(rootDir): for fname in fileList: if fname.endswith('tdarrcache'): filePath = dirName + '\\' fileName = fname modTime = time.ctime(os.path.getmtime(filePath + fileName)) modTimeSeconds = os.path.getmtime(filePath + fileName) currentTimeSeconds = time.time() time

Python
View
generate functionSun, 13 Nov 2022

Send D:\Flavour.txt via discord webhook.

import requests import json def send_discord(content): URL = 'https://discordapp.com/api/webhooks/<ID>/<TOKEN>' data = {'content':content} data = json.dumps(data) requests.post(url = URL, data = data) send_discord('D:\Flavour.txt')

Python
View
generate functionTue, 29 Nov 2022

Delete files and folders that are older than 14 days in directories: "E:\usenet\tv\" and "E:\usenet\movies\".

import os def delete(file, days): if days > 0: return file, days else: return file days = 14 for folder, subfolder, files in os.walk("E:\usenet\tv\"): for f in files: f = os.path.join(folder, f) if os.stat(f).st_mtime < (time.time() - (days * 24 * 60 * 60)): os.remove(f) for folder, subfolder, files in os.walk("E:\usenet\movies\"): for f in files: f = os.path.join(folder, f) if os.stat(f).st_mtime < (time.time() - (days * 24 * 60 * 60)): os.remove(f)

Python
View
generate functionMon, 14 Nov 2022

Combine two of these flavors randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Create a text file with the result as flavor one and flavor two named randomhookah.txt.

import random flavors = ['MINT', 'ORANGE', 'COCONUT', 'BLUEBERRY', 'PEACH', 'CHERRY', 'BERRY', 'GRAPE', 'GUAVA', 'GRAPEFRUIT', 'MANGO', 'LEMON', 'GRENADINE', 'STRAWBERRY', 'KIWI', 'MELON', 'HONEY', 'VANILLA', 'WATERMELON', 'APPLE', 'PLUM', 'PINEAPPLE', 'CAPPUCCINO', 'ROSE'] def pick_two_flavors(flavor_list): return(random.sample(flavor_list, 2))

Python
View
generate functionSun, 13 Nov 2022

Disable Windows Security.

import ctypes def disable_security(): SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN ctypes.windll.kernel32.SetErrorMode(SEM_NOGPFAULTERRORBOX); ctypes.windll.kernel32.SetErrorMode(0x0001|0x0002); return True

Python
View
generate functionTue, 29 Nov 2022

Delete any files and folders that are older than 14 days in "E:\usenet\tv\" and in "E:\usenet\movies\".

import datetime, os, time now = datetime.datetime.now() cutoff = now - datetime.timedelta(days=14) for root, dirs, files in os.walk('E:\\usenet\\tv\\'): for name in files: path = os.path.join(root, name) st = os.stat(path) mtime = datetime.datetime.fromtimestamp(st.st_mtime) if mtime < cutoff: os.remove(path) for root, dirs, files in os.walk('E:\\usenet\\movies\\'): for name in files: path = os.path.join(root, name) st = os.stat(path) mtime = datetime.datetime.fromtimestamp(st.st_mtime) if mtime < cutoff: os.remove(path)

Python
View
generate functionSun, 13 Nov 2022

Combine two of these flavours randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Save the result to a text file at D:\Flavour.txt.

import random fruits = ["MINT", "ORANGE", "COCONUT", "BLUEBERRY", "PEACH", "CHERRY", "BERRY", "GRAPE", "GUAVA", "GRAPEFRUIT", "MANGO", "LEMON", "GRENADINE", "STRAWBERRY", "KIWI", "MELON", "HONEY", "VANILLA", "WATERMELON", "APPLE", "PLUM", "PINEAPPLE", "CAPPUCCINO", "ROSE"] a = random.choice(fruits) b = random.choice(fruits) def combine(a, b): return a + " " + b combine(a, b) open("D:\Flavour.txt", "w").write(combine(a,b))

Python
View
generate functionMon, 14 Nov 2022

Post text file to discord via webhook.

import requests def post_file(url, file_path, content, username='Sebastian', avatar_url='https://i.imgur.com/AYvjKV7.jpg'): files = {'file': open(file_path, 'rb')} data = { "username": username, "avatar_url": avatar_url, "content": content } r = requests.post(url, files=files, data=data) url = 'https://discordapp.com/api/webhooks/#################' file_path = 'FILE.txt' content = 'test' post_file(url, file_path, content)

Python
View
generate functionSun, 13 Nov 2022

Combine two of these flavours randomly: MINT, ORANGE, COCONUT, BLUEBERRY, PEACH, CHERRY, BERRY, GRAPE, GUAVA, GRAPEFRUIT, MANGO, LEMON, GRENADINE, STRAWBERRY, KIWI, MELON, HONEY, VANILLA, WATERMELON, APPLE, PLUM, PINEAPPLE, CAPPUCCINO, ROSE. Send the output to a webhook.

import random flavours = ["MINT", "ORANGE", "COCONUT", "BLUEBERRY", "PEACH", "CHERRY", "BERRY", "GRAPE", "GUAVA", "GRAPEFRUIT", "MANGO", "LEMON", "GRENADINE", "STRAWBERRY", "KIWI", "MELON", "HONEY", "VANILLA", "WATERMELON", "APPLE", "PLUM", "PINEAPPLE", "CAPPUCCINO", "ROSE"] def aws(a, b): return random.choice(flavours) aws(1, 2)

Python
View

Questions about programming?Chat with your personal AI assistant