Skip to content

Instantly share code, notes, and snippets.

@blacktwin
blacktwin / mark_guest_unwatched.py
Last active February 22, 2020 03:42
Mark everything shared with guest account as unwatched.
from plexapi.server import PlexServer
import requests
# Edit these
PLEX_URL = ''
PLEX_TOKEN = ''
#
sess = requests.Session()
sess.verify = False
@blacktwin
blacktwin / botulism.json
Last active October 18, 2019 15:57
Mapping Infant Botulism Cases in the US from 1975-2017
{
"meta" : {
"view" : {
"id" : "66i6-hisz",
"name" : "Botulism",
"attribution" : "Division of Foodborne, Waterborne, and Environmental Diseases",
"attributionLink" : "https://www.cdc.gov/botulism/surveillance.html",
"averageRating" : 0,
"category" : "Foodborne, Waterborne, and Related Diseases",
"createdAt" : 1558625323,
@blacktwin
blacktwin / sync_playlists_to_users.py
Created November 15, 2017 12:05 — forked from JonnyWong16/sync_playlists_to_users.py
Sync Plex playlists to shared users.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Description: Sync Plex playlists to shared users.
# Author: /u/SwiftPanda16
# Requires: plexapi, requests, xmltodict
import requests
import xmltodict
@blacktwin
blacktwin / rand_albums_playlist.py
Last active July 23, 2017 21:09
Create playlist of random albums.
# pip install plexapi
from plexapi.server import PlexServer
import random
### Edit Settings ###
PLEX_URL = 'http://localhost:32400'
TOKEN = 'xxxx'
MUSIC_LIBRARY = 'Music'
PLAYLIST_TITLE = 'Random Album Playlist'
@blacktwin
blacktwin / xml_collect.py
Created July 18, 2017 13:32
Collect Plex sessions and metadata xmls.
import requests
import platform
from uuid import getnode
import sys
# PlexPy argument {rating_key}
## EDIT THESE SETTINGS ##
PLEX_HOST = '127.0.0.1'
@blacktwin
blacktwin / bypass_auth_name.py
Created July 12, 2017 14:55
Use PlexPy to pull last IP address from user and add to List of IP addresses and networks that are allowed without auth in Plex..
'''
Use PlexPy to pull last IP address from user and add to List of IP addresses and networks that are allowed without auth in Plex.
optional arguments:
-h, --help show this help message and exit
-u [ ...], --users [ ...]
Space separated list of case sensitive names to process. Allowed names are:
(choices: {List of all Plex users} )
(default: None)
-c [], --clear [] Clear List of IP addresses and networks that are allowed without auth in Plex:
@blacktwin
blacktwin / plexapi_search_file.py
Created July 12, 2017 12:58
Find full path for Plex items.
from plexapi.server import PlexServer
PLEX_URL = 'http://localhost:32400'
PLEX_TOKEN = 'xxxxx'
plex = PlexServer(PLEX_URL, PLEX_TOKEN)
sections = plex.library.sections()
titles = [titles for libraries in sections for titles in libraries.search('star')]
for title in titles:
try:
@blacktwin
blacktwin / notify_added_custom.py
Last active November 28, 2024 01:43
Send an email with what was added to Plex in the past week using PlexPy. Email includes title (TV: Show Name: Episode Name; Movie: Movie Title), time added, image, and summary.
"""
Send an email with what was added to Plex in the past week using PlexPy.
Email includes title (TV: Show Name: Episode Name; Movie: Movie Title), time added, image, and summary.
Uses:
notify_added_lastweek.py -t poster -d 1 -u all -i user1 user2 -s 250 100
# email all users expect user1 & user2 what was added in the last day using posters that are 250x100
notify_added_lastweek.py -t poster -d 7 -u all
# email all users what was added in the last 7 days(week) using posters that are default sized
@blacktwin
blacktwin / create_wait_kill_trans.py
Last active October 17, 2019 04:13
Receive session_key from PlexPy when paused. Use session_id to create sub-script to wait for X time then check if transcoding still paused. If so, kill.
'''
kill_transcode function from https://gist.github.com/Hellowlol/ee47b6534410b1880e19
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on pause
PlexPy > Settings > Notification Agents > Scripts > Gear icon:
Playback Pause: create_wait_kill_trans.py
PlexPy > Settings > Notifications > Script > Script Arguments:
{session_key}