Skip to content

Instantly share code, notes, and snippets.

@JonnyWong16
JonnyWong16 / audit_guids.py
Last active July 17, 2024 20:16
Audit duplicate Plex guids
from plexapi.server import PlexServer
def duplicate_guids(library, libtype=None):
for item in library.all(libtype):
guid_map = {
'imdb': [],
'tmdb': [],
'tvdb': [],
}
@JonnyWong16
JonnyWong16 / save_posters.py
Last active July 16, 2024 21:35
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 December 12, 2024 15:42
Selects the default TMDB poster and art 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 July 28, 2024 11:32
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/*