Skip to content

Instantly share code, notes, and snippets.

View Hellowlol's full-sized avatar

Steffen Fredriksen Hellowlol

  • Kristiansand, Norway
View GitHub Profile
@Hellowlol
Hellowlol / assertbastard.py
Created January 19, 2017 22:51
plexapi assert bastard py2
def assertme(m, monsterassert=True):
with open('asserted.txt', 'w') as f:
todo = []
def inner(m=None, override_name=''):
keys = sorted([k for k in m.__dict__.keys() if not k.startswith('_')])
tags = ['genres', 'roles', 'writers', 'directors', 'writers']
l_type_to_inspect = ['videoStreams', 'part', 'subtitleStreams',
'media', 'audioStreams', 'parts', 'streams', 'video']
for k in keys:
# pip instaal pyqrcode
# pip install pypng
import pyqrcode
url = pyqrcode.create('http://plexpy.rocks')
loads_of_info = pyqrcode.create('I::LIKE::BIG::BUTTS::AND::I::CANT::LIE')
url.png('url.png')
loads_of_info.png('info.png')
@Hellowlol
Hellowlol / http.py
Last active October 16, 2016 18:15
Better http for py2
from functools import partial
from multiprocessing.dummy import Pool as ThreadPool
import urllib3
try:
from ujson import dumps
except ImportError:
try:
from simplejson import dumps
import math
def convert_size(size, ):
if (size == 0):
return '0B'
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
i = int(math.floor(math.log(size,1024)))
p = math.pow(1024,i)
s = round(size/p,2)
return '%s %s' % (s,size_name[i])
@Hellowlol
Hellowlol / media_cli_parser.py
Created July 17, 2016 23:14
Parser for mediainfo cli in python
import subprocess
import json
def get_media_info(path, format='dict'):
""" Note this is media info cli """
cmd = 'mediainfo "%s"' % (path)
process = subprocess.Popen(cmd,
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
@Hellowlol
Hellowlol / simple_convert.py
Created July 13, 2016 16:22 — forked from onedr0p/simple_convert.py
A simple script to convert media files to MP4 for a better Plex experiance
import os
import sys
import time
import platform
import subprocess
import urllib2
import logging
""" Are we windoze or linux """
is_windows = any(platform.win32_ver())
@Hellowlol
Hellowlol / parse_plex_history.py
Last active April 7, 2016 23:16
Parse plexhistory
import requests
import time
from collections import Counter
from functools import wraps
import arrow
def timeme(func):
@wraps(func)
def inner(*args, **kwargs):
@Hellowlol
Hellowlol / restart_plex.bat
Last active February 21, 2020 01:53
Restart plex plexpyscript
REM Add this script to Plex down and/or Plex remote down to restart plex if
REM server is unreachable.
TASKKILL /f /im "Plex Media Server.exe"
TASKKILL /f /im "PlexScriptHost.exe"
"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe"
from collections import Counter
urllib2
from uuid import getnode
import platform
import json
ip = ''
port = ''
plextoken = ''
url = 'http://%s:%s/' % (ip, port)
@Hellowlol
Hellowlol / kill_a_stream.py
Last active January 18, 2021 14:37
Plexpy script, kill a plex stream
"""
This is a simple script showing how you can used plexpys notifications system to kill a stream
Possible plexpyargs: -tk {transcode_key} -u {username} -td {transcode_decision} -t 20:20 -ln Secret_tash
Instructions:
1. Save the script somewhere on your computer as kill_a_stream.py.