Skip to content

Instantly share code, notes, and snippets.

View xthesaintx's full-sized avatar

Stephen Garrett xthesaintx

View GitHub Profile
@xthesaintx
xthesaintx / wiim.py
Last active April 22, 2023 02:01
Switch Wiim to Line-in
#!/usr/bin/env python3
import requests
import json
#disable the ssl warning as Wiim SSL cert is trash
from urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
#Set vars for the modes to switch to
@xthesaintx
xthesaintx / SpotifyTrackValidate.py
Created December 20, 2022 02:45
Checks the Track ID input from CLI "SpotifyTackValidate.py TRACKID" output VALID or ERROR
#!/usr/bin/env python3
import spotipy
import datetime
import pprint
import os
import sys
# from prompter import prompt, yesno
from spotipy.oauth2 import SpotifyOAuth
# Import the os module
@xthesaintx
xthesaintx / Spotify_Recommendations.py
Last active December 21, 2022 00:41
Creates a spotify playlist based on a track ID
#!/usr/bin/env python3
####
## Replace XXXX with your details
####
import spotipy
import datetime
import pprint
import os
import sys
@xthesaintx
xthesaintx / qbit_completed.py
Created March 22, 2022 01:14
Script that will remove completed torrents that are older than 7 days from the QbitTorrent queue
import qbittorrentapi
import datetime
today = datetime.datetime.now()
#Set age (days) to remove
older = 7
#Converts UTC time to datetime
def utc(x):
dt = datetime.datetime.fromtimestamp(x)
@xthesaintx
xthesaintx / watch.py
Last active March 2, 2022 21:40
Watch Folder - The watched folder feature of qbittorrent on the Pi is pretty flaky and I find I have to keep resetting it. So I wrote my own in Python... It's pretty hacky to get the script to wait for the file to be finished writing (as depending on where the file is copied from 2 to god knows how many events watch_dog will raise on closed), an…
import time
import subprocess
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from watchdog.events import PatternMatchingEventHandler
import qbittorrentapi
import os
import logging
import shutil
logging.basicConfig(filename='/home/pi/Scripts/watch.log', filemode='a', format ='%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%d-%m-%Y %H:%M:%S' )
@xthesaintx
xthesaintx / AudioSwitcher.py
Last active January 29, 2022 02:36
Python Script that switches through audio output on Mac, can add uid to an ignore list, pops up a notification with output name. USE: I bind the script to a shortcut and add a keyboard shortcut to switch between audio outputs. (Uses https://github.com/deweller/switchaudio-osx)
#!/usr/bin/env python3
import os
import subprocess as sp
import json
def notify(title, text):
os.system("""
osascript -e 'display notification "{}" with title "{}"'
""".format(text, title))
@xthesaintx
xthesaintx / GDriveGrab.py
Last active January 18, 2022 19:38
Headless Raspberry Pi Python script to grab torrent files from a Google Drive Folder and load them into qbittorrent. Uses PyDrive2 GetContentIOBuffer() to aviod downloading a torrent file. Logs the files grabbed into a log file and places that on the GDrive folder as well as locally, also logs the contents (only 1 day old) of a local folder.
#!/usr/bin/env python3
##
## Requires pydrive2, qbittorrent-api and setting up Google API
## client_secrets.json put in the same folder as script
## Must be run on a machine with a browser first to generate mycreds.txt
##
import os
import requests
import filecmp
import shutil
@xthesaintx
xthesaintx / playlists.py
Last active November 18, 2021 23:20
Makes a copy of Spotify's Discover Weekly or Release Radar depending on day of week [M-Th = DW / F-Su = RR] and names it [DW/RR] - [YEAR] - [WEEK]
#!/usr/bin/env python3
import spotipy
import datetime
import pprint
from spotipy.oauth2 import SpotifyOAuth
# CHECKS IF PLAYLIST EXSISTS
def does_playlist_exist(u,s,pl):
x = s.user_playlists(u)
for x in x['items']:
@xthesaintx
xthesaintx / JobFolders.command
Last active April 5, 2020 23:50
Creates X number of Job Folders and Sub Folders, checks to see if the job number is in use and other validation. Allows to output the folders as a csv split by job number and name.
#!/usr/bin/env python3
import sys
import getopt
import os
import re
import csv
###---HOUSEKEEPING---###
#define home dir
@xthesaintx
xthesaintx / DropShadow - Animate CC
Created October 18, 2018 01:57
Drop-Shadow Action Script (Global) Animate CC
// Global
function newShadow (ob)
{
ob.shadow = new createjs.Shadow("rgba(0,0,0,.3)",1,1,10);
}
//The object needs to be a Symbol -> Movie Clip
//It needs to be named on the timeline
//Drop shadow will appear when script is implemented on the timeline
//