Skip to content

Instantly share code, notes, and snippets.

@blha303
blha303 / hbget.py
Last active January 1, 2024 04:28
Humble Bundle: save all torrents
# pypi:humblebundle has to deal with captchas. I can't be bothered.
import requests
import json
import subprocess
keys = [k["gamekey"] for k in json.loads(""" #paste contents of https://www.humblebundle.com/api/v1/user/order here
""")
# Open your browser's Network console while going to the above url, find the headers, paste them below
headers = {"Cookie": "", "User-Agent": ""}
@blha303
blha303 / clickviewvids.py
Created April 8, 2014 04:45
Get videos from Clickview server
import requests
import sys
import os
from bs4 import BeautifulSoup as Soup
if len(sys.argv) < 2:
print sys.argv[0] + " <IP of server / ID of video> [ID of video] - Second arg is needed if first arg is IP"
sys.exit(2)
CVSERVER = "10.232.66.197"
@blha303
blha303 / discord_presence_pbx.py
Last active December 3, 2022 21:04
connects to an asterisk manager and picks up ExtensionStatus messages. ties into https://gist.github.com/blha303/37e83f320b009de19e7a6c140f51e8d5
import socket
from requests import get
EXTEN = "1"
presence_api = "http://127.0.0.1:8081"
auth = ("me", "aa")
pbx_ip = "127.0.0.2"
def process_event(resp):
d = {}
@blha303
blha303 / discord_presence_working.py
Created March 17, 2019 19:38
A webpage for updating my presence while I'm at work showing what I'm up to
from pypresence import Presence # https://github.com/qwertyquerty/pypresence
from flask import *
from requests import get
from time import sleep
client_id = "556918123421368329"
RPC = Presence(client_id)
RPC.connect()
app = Flask(__name__)
@blha303
blha303 / discord_presence_plex.py
Last active December 3, 2022 21:04
uses Tautulli as an easy way to get plex session data. has to be run on the same machine as your discord desktop client for access to RPC
from pypresence import Presence # https://github.com/qwertyquerty/pypresence
from requests import get
from time import sleep
from sys import exit
client_id = "556909532417228919"
user = "blha303"
tautulli_instance = "https://tau.home.b303.me" # https://github.com/Tautulli/Tautulli
RPC = Presence(client_id)
#!/usr/bin/env python3
import zlib
import os
import sys
import argparse
def crc32_file(filename):
with open(filename, "rb") as f:
return hex(zlib.crc32(f.read())).upper()[2:].zfill(8)
@blha303
blha303 / portopen.php
Created January 28, 2017 11:50
A script to check if a given port is open on the connecting host. IP ranges included are for cloudflare, replace with an array containing your proxy server IP ranges
<?php
// A script to check if a given port is open on the connecting host.
// IP ranges included are for cloudflare, replace with an array containing your proxy server IP ranges
// https://b303.me/portopen.php?port=80
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
function cidr_match($ip, $ranges) {
$out = array();
foreach ($ranges as $range) {
list ($subnet, $bits) = explode('/', $range);
@blha303
blha303 / plexnp.py
Last active December 3, 2022 21:04
A script to report what people are watching on your Plex server
from plexapi.server import PlexServer
import sys
plex = PlexServer("http://172.16.17.10:32400")
now_playing = plex.query("/status/sessions")
if not now_playing:
print("Nobody's watching anything")
sys.exit(0)
sessions = []
def hms(mil):
s,mil = divmod(int(mil), 1000)
@blha303
blha303 / recursive_checksum.py
Last active December 3, 2022 21:03
A tool to generate checksums for all files in current directory and notify when mismatches with an existing file are found
#!/usr/bin/env python
import os
import json
from hashlib import md5
rootdir = os.getcwd()
CHECKSUMS = "checksums.json"
@blha303
blha303 / OCRrainwaveNP.php
Last active December 3, 2022 20:31
Python and PHP scripts for getting Now Playing from ocr.rainwave.cc. MIT license
<?php
# Because sometimes it's easier to load up a web browser.
# http://blha303.com.au/rainwave
# https://github.com/blha303/Rainwave-NowPlaying
header("Access-Control-Allow-Origin: *");
$pagecontent = file_get_contents("http://ocr.rainwave.cc/");
preg_match_all("/PRELOADED_APIKEY = '(.*?)'/", $pagecontent, $matches);
$url = "http://ocr.rainwave.cc/sync/2/init";
$data = array('refresh' => 'full',