Skip to content

Instantly share code, notes, and snippets.

View FloPinguin's full-sized avatar

FloPinguin FloPinguin

View GitHub Profile
@FloPinguin
FloPinguin / twitch-vod-id.py
Created January 27, 2020 16:57
This python script will output the past broadcasts vod ids of a specific user (Using the new Twitch API v5). You need to replace USERID with an actual user id. To obtain the user id of a streamer, an api call to a specific vod will help: https://api.twitch.tv/helix/videos?id=VODID. The response will include a user_id. CLIENTID also needs to be r…
import requests
import json
r = requests.get("https://api.twitch.tv/helix/videos?user_id=USERID&type=archive", headers={"Client-ID":"CLIENTID"})
j = json.loads(r.text)
for vod in j['data']:
print(vod['id'])
@FloPinguin
FloPinguin / kill-specific-java-process.bat
Created January 27, 2020 17:01
Killing a specific java process on windows
start "MyProgram" "C:/Program Files/Java/jre1.8.0_201/bin/java.exe" -jar MyProgram.jar
taskkill /F /FI "WINDOWTITLE eq MyProgram" /T
@FloPinguin
FloPinguin / ia-youtube-archive-get-size.py
Created January 27, 2020 17:10
Get the video count and size in GB of a internet archive item which contains mp4s. ia (https://github.com/jjjake/internetarchive) must be installed.
import subprocess
import io
out = subprocess.check_output("ia list " + input() + " -c size -g *.mp4", shell=True)
string = io.StringIO(out.decode("utf-8"))
count = 0
total_bytes = 0
for line in string:
count += 1
@FloPinguin
FloPinguin / check-youtube-online.py
Created January 27, 2020 17:28
In a directory structure full of .info.json files (Generated by youtube-dl), check which youtube videos are no longer online (And write them to a file).
import os
import sys
import json
import subprocess
import requests
import datetime
def log(msg):
sys.stdout.buffer.write((msg + "\n").encode('utf8'))
@FloPinguin
FloPinguin / dl-youtube-comments.py
Created January 27, 2020 17:32
In a directory structure full of .info.json files (Generated by youtube-dl), get the comments of youtube videos and save them as .comments files (https://github.com/philbot9/youtube-comment-scraper-cli must be installed)
import os
import sys
import json
import subprocess
import datetime
rootdir = 'U:/Hoard'
def log(msg):
sys.stdout.buffer.write((msg + "\n").encode('utf8'))
@FloPinguin
FloPinguin / check-internet.bat
Created January 27, 2020 17:35
Only run .bat after a internet connection is established
:ping
timeout 15
set target=www.google.com
ping %target% -n 1 | find "TTL="
if errorlevel==1 goto ping
DO SOMETHING
@FloPinguin
FloPinguin / index.html
Created January 27, 2020 17:48
Hashtag Mixer (Very simple webapp)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hashtag Mixer</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
@FloPinguin
FloPinguin / check-internet-connection.py
Created February 2, 2020 13:54
Wait for internet connection in python
import socket
import time
def is_connected():
try:
socket.create_connection(("www.google.com", 80))
return True
except OSError:
pass
return False
@FloPinguin
FloPinguin / wait-for-network-share.py
Created February 5, 2020 16:37
Wait for network share in python
import os
import time
share = 'U:'
while True:
print("Checking share availability")
if os.path.isdir(share):
print ("Available!")
raise SystemExit
def send_telegram(msg, log=False):
r = None
try:
token = ""
if log:
token = ""
for start in range(0, len(msg), 4000):
data = {'chat_id': 123456789, 'text': msg[start:start+4000]}
r = requests.post("https://api.telegram.org/bot" + token + "/sendMessage", timeout=30, data=data)
r.raise_for_status()