Skip to content

Instantly share code, notes, and snippets.

@blacktwin
blacktwin / aired_today_playlist.py
Created February 26, 2017 22:25
Create a Plex Playlist with what was aired on this today's month-day, sort by oldest first, using PlexAPI
"""
Create a Plex Playlist with what was aired on this today's month-day, sort by oldest first.
If Playlist from yesterday exists delete and create today's.
If today's Playlist exists exit.
"""
import operator, time
from plexapi.server import PlexServer
import requests
@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 / plexapi_delete_playlists.py
Created February 3, 2017 20:02
Delete all playlists from Plex using PlexAPI
"""
Delete all playlists from Plex using PlexAPI
https://github.com/mjs7231/python-plexapi
"""
from plexapi.server import PlexServer
import requests
baseurl = 'http://localhost:32400'
@blacktwin
blacktwin / plex_theme_songs.py
Last active April 16, 2024 02:47
Download theme songs from Plex TV Shows.
'''
Download theme songs from Plex TV Shows. Theme songs are mp3 and named by shows as displayed by Plex.
Songs are saved in a 'Theme Songs' directory located in script's path.
'''
from plexapi.server import PlexServer
# pip install plexapi
import os
@blacktwin
blacktwin / plex_api_poster_pull.py
Last active March 17, 2024 19:30
Pull Movie and TV Show poster images from Plex.
'''
Pull Movie and TV Show poster images from Plex.
Save to Movie and TV Show directories in scripts working directory.
'''
from plexapi.server import PlexServer
# pip install plexapi
import re
@blacktwin
blacktwin / kill_trans_exp_audio.py
Last active December 13, 2023 02:56
Kill Plex video transcoding streams only. All audio streams are left alone. Kill message based on platform.
"""
Kill Plex video transcoding streams only. All audio streams are left alone.
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on playback start
PlexPy > Settings > Notification Agents > Scripts > Gear icon:
Playback Start: kill_trans_exp_audio.py
"""
@blacktwin
blacktwin / find_plex_meta.py
Last active July 19, 2023 15:53
Find location of Plex metadata.
'''
Find location of Plex metadata.
find_plex_meta.py -s adventure
pulls all titles with adventure in the title
or
find_plex_meta.py -s adventure -m movie
pulls all movie titles with adventure in the title
'''
@blacktwin
blacktwin / kill_more_than.py
Last active July 15, 2023 19:05
If user has 2* or more concurrent streams and the IP of the 2nd stream differs from 1st kill 2nd. If 2nd stream IP is the same as 1st stream don't kill.
"""
If user has 2* or more concurrent streams and the IP of the 2nd stream differs from 1st kill 2nd.
If 2nd stream IP is the same as 1st stream don't kill.
*PlexPy > Settings > Notification> User Concurrent Stream Threshold
The number of concurrent streams by a single user for PlexPy to trigger a notification. Minimum 2.
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on user concurrent streams
@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 / stream_limiter_ban_email.py
Last active October 27, 2020 21:33
This is indented to restrict a user to the LIMIT amount of concurrent streams. User will be warned, punished, and banned completely if violations continue.
"""
Share functions from https://gist.github.com/JonnyWong16/f8139216e2748cb367558070c1448636
Once user stream count hits LIMIT they are unshared from libraries expect for banned library.
Once user stream count is below LIMIT and banned library video is watched their shares are restored.
Once violation count have been reached ban permanently.
Caveats:
Unsharing doesn't pause the stream.
After unsharing user can pause but not skip ahead or skip back.