Skip to content

Instantly share code, notes, and snippets.

@JonnyWong16
JonnyWong16 / save_posters.py
Last active March 26, 2024 07:41
Saves poster images from Plex to same folder as the media files.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Description: Saves poster images from Plex to same folder as the media files.
Author: /u/SwiftPanda16
Requires: plexapi, tqdm (optional)
Usage:
* Save posters for an entire library:
python save_posters.py --library "Movies"
@JonnyWong16
JonnyWong16 / select_tmdb_poster.py
Last active April 23, 2024 08:08
Selects the default TMDB poster for movies in a Plex library if the current poster is from Gracenote.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Description: Selects the default TMDB poster if no poster is selected
or the current poster is from Gracenote.
Author: /u/SwiftPanda16
Requires: plexapi
Usage:
* Change the posters for an entire library:
@JonnyWong16
JonnyWong16 / random_episode_smart_playlist.py
Created January 12, 2024 22:05
Creates a Plex smart playlist with random episodes from multiple TV shows while keeping the episodes in order for each show.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Description: Creates a Plex smart playlist with random episodes from multiple TV shows
while keeping the episodes in order for each show.
Author: /u/SwiftPanda16
Requires: plexapi
'''
@JonnyWong16
JonnyWong16 / download_photo_thumbnails.py
Last active December 29, 2023 01:40
Downloads all photo thumbnails recursively for a photo album in Plex.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Description: Downloads all photo thumbnails recursively for a photo album in Plex.
Author: /u/SwiftPanda16
Requires: plexapi
'''
import os
@JonnyWong16
JonnyWong16 / random_episode_playlist.py
Last active February 1, 2024 19:38
Creates a Plex playlist with random episodes from multiple TV shows while keeping the episodes in order for each show.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Description: Creates a Plex playlist with random episodes from multiple TV shows
while keeping the episodes in order for each show.
Author: /u/SwiftPanda16
Requires: plexapi
'''
@JonnyWong16
JonnyWong16 / all_guids.py
Created August 3, 2023 00:03
Dump all Plex TV library guids to json file
import json
import requests
from plexapi.server import PlexServer
PLEX_URL = 'http://localhost:32400'
PLEX_TOKEN = 'XXXXXXXXXXXXXXXXXXXX'
TVSHOW_LIBRARY = 'TV Shows'
TMDB_TOKEN = ''
@JonnyWong16
JonnyWong16 / refresh_metadata.py
Last active January 9, 2023 23:55
Refresh metadata for an item in Plex
import argparse
import os
from plexapi.server import PlexServer
PLEX_URL = os.getenv('PLEX_URL')
PLEX_TOKEN = os.getenv('PLEX_TOKEN')
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--rating_key', required=True, type=int)
@JonnyWong16
JonnyWong16 / special_episode_to_season.py
Created August 30, 2022 17:38
Move a TV show's special episode to it's own season in Plex
from plexapi.server import PlexServer
plex = PlexServer('http://localhost:32400', token='XXXXXXXXXXXXXXXXXXXX')
tvshows = plex.library.section('TV Shows')
show = tvshows.get('Dragon Ball')
# Get season 2
season = show.season(2)
# Lock all the season 2 episode metadata
@JonnyWong16
JonnyWong16 / openPlexSearch.user.js
Last active January 31, 2024 19:35
Open the Plex search page when pressing enter in the search box.
// ==UserScript==
// @name Open Plex Serach Page on Enter
// @namespace https://app.plex.tv
// @version 1.1
// @description Open the Plex search page when pressing enter in the search box.
// @author JonnyWong16
// @homepage https://gist.github.com/JonnyWong16/1ebd38a5f5872408e5b840ed28006dec
// @downloadURL https://gist.github.com/JonnyWong16/1ebd38a5f5872408e5b840ed28006dec/raw/openPlexSearch.user.js
// @updateURL https://gist.github.com/JonnyWong16/1ebd38a5f5872408e5b840ed28006dec/raw/openPlexSearch.user.js
// @match https://app.plex.tv/*
@JonnyWong16
JonnyWong16 / mark_watched.py
Last active November 27, 2023 17:12
Automatically mark a video (movie, show, season, or episode) as played in Plex for a specific users.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Description: Automatically mark a video (movie, show, season, or episode)
# as played in Plex for specific users.
# Author: /u/SwiftPanda16
# Requires: plexapi
#
# Tautulli script trigger:
# * Notify on watched