Skip to content

Instantly share code, notes, and snippets.

View Hellowlol's full-sized avatar

Steffen Fredriksen Hellowlol

  • Kristiansand, Norway
View GitHub Profile
@JonnyWong16
JonnyWong16 / sync_playlists_to_users.py
Last active April 8, 2025 20:09
Sync Plex playlists to shared users.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Description: Sync Plex playlists to shared users.
# Author: /u/SwiftPanda16
# Requires: plexapi
from plexapi.exceptions import NotFound
from plexapi.server import PlexServer
#!/usr/bin/env python
'''Crop an image to just the portions containing text.
Usage:
./crop_morphology.py path/to/image.jpg
This will place the cropped image in path/to/image.crop.png.
For details on the methodology, see
@JonnyWong16
JonnyWong16 / update_all_metadata.py
Last active March 28, 2025 12:24
Updates all metadata in the Tautulli database after moving Plex libraries.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Description: Updates all metadata in the Tautulli database after moving Plex libraries.
# Author: /u/SwiftPanda16
# Requires: plexapi, requests
from plexapi.server import PlexServer
import requests
@rgegriff
rgegriff / encoders.py
Last active February 11, 2021 19:30
JSON Encoder and Decoder for datetime and timedelta
# Taken from http://taketwoprogramming.blogspot.com/2009/06/subclassing-jsonencoder-and-jsondecoder.html
from json import JSONEncoder, JSONDecoder
class DateTimeAwareJSONEncoder(JSONEncoder):
"""
Converts a python object, where datetime and timedelta objects are converted
into objects that can be decoded using the DateTimeAwareJSONDecoder.
"""
def default(self, obj):
if isinstance(obj, datetime):
return {
@JonnyWong16
JonnyWong16 / update_plex_movie_ratings.py
Last active November 15, 2024 19:29
Update Plex movie ratings from IMDB or Rotten Tomatoes
# -*- coding: utf-8 -*-
#------------------------------------------------------------------------------
#
# Plex movie ratings script by /u/SwiftPanda16
#
# *** Use at your own risk! ***
# *** I am not responsible for damages to your Plex server or libraries. ***
#
#------------------------------------------------------------------------------
@mohit-0212
mohit-0212 / read_video.py
Created February 23, 2018 21:54
Detecting intro from video frames
import cv2
import numpy as np
import matplotlib.pyplot as plt
vid_frame = cv2.VideoCapture('/path for/video file/')
length = vid_frame.get(cv2.CAP_PROP_FRAME_COUNT)
fps = vid_frame.get(cv2.CAP_PROP_FPS)
num_frames = int(fps*300) #number of frames in first 5 minutes
@mohit-0212
mohit-0212 / read_audio.py
Created February 23, 2018 22:13
Analysing audio signals of a video
import subprocess
import numpy as np
import scipy
import librosa
import matplotlib.pyplot as plt
file_input = "/path for/video file/"
file_output = "/path for/output audio file.wav/"
command = "ffmpeg -i " + file_input +" -t 300 -codec:a pcm_s16le -ac 1 "+ file_output #converts the first 5 minutes of video file to wav output
@rene-d
rene-d / colors.py
Last active May 8, 2025 13:49
ANSI color codes in Python
# SGR color constants
# rene-d 2018
class Colors:
""" ANSI color codes """
BLACK = "\033[0;30m"
RED = "\033[0;31m"
GREEN = "\033[0;32m"
BROWN = "\033[0;33m"
BLUE = "\033[0;34m"
@kellerza
kellerza / oauth2_session.py
Last active February 12, 2025 19:29
OAuth2 authentication with aiohttp and oauthlib (based on requests_oauthlib)
"""OAuth2Support for aiohttp.ClientSession.
Based on the requests_oauthlib class
https://github.com/requests/requests-oauthlib/blob/master/requests_oauthlib/oauth2_session.py
"""
# pylint: disable=line-too-long,bad-continuation
import logging
from oauthlib.common import generate_token, urldecode
from oauthlib.oauth2 import WebApplicationClient, InsecureTransportError
@kauffmanes
kauffmanes / install_anaconda.md
Last active April 27, 2025 07:33
Install Anaconda on Windows Subsystem for Linux (WSL)

Thanks everyone for commenting/contributing! I made this in college for a class and I no longer really use the technology. I encourage you all to help each other, but I probably won't be answering questions anymore.

This article is also on my blog: https://emilykauffman.com/blog/install-anaconda-on-wsl

Note: $ denotes the start of a command. Don't actually type this.

Steps to Install Anaconda on Windows Ubuntu Terminal

  1. Install WSL (Ubuntu for Windows - can be found in Windows Store). I recommend the latest version (I'm using 18.04) because there are some bugs they worked out during 14/16 (microsoft/WSL#785)
  2. Go to https://repo.continuum.io/archive to find the list of Anaconda releases
  3. Select the release you want. I have a 64-bit computer, so I chose the latest release ending in x86_64.sh. If I had a 32-bit computer, I'd select the x86.sh version. If you accidentally try to install the wrong one, you'll get a warning in the terminal. I chose `Anaconda3-5.2.0-Li