Skip to content

Instantly share code, notes, and snippets.

@TiloGit
Last active October 27, 2025 05:04
Show Gist options
  • Save TiloGit/51ba118216561f7acdda96522d5d4db2 to your computer and use it in GitHub Desktop.
Save TiloGit/51ba118216561f7acdda96522d5d4db2 to your computer and use it in GitHub Desktop.
Download entire Season from Plex with plexapi (tested with plex plus pass account)
#in bash run this for env
#source my-venv/bin/activate
#python
from datetime import datetime
import os
from plexapi.server import PlexServer
baseurl = 'https://50-____removed____2a1922.plex.direct:32400'
token = 'X---removed---Kb'
plex = PlexServer(baseurl, token)
print(datetime.now().isoformat() + " _______START SCRIPT ")
# --- Search for the show ---
item_name = "Balu" # Change this to the show you want
itemlist = plex.library.search(item_name, libtype='show')
for item in itemlist:
print(datetime.now().isoformat() + " with: "+ item.title)
##action list size
total_size = 0
for episode in item.episodes():
#print(datetime.now().isoformat() + " with Ep: "+ episode.title)
for media in episode.media:
for part in media.parts:
if part.size:
print(datetime.now().isoformat() + " Now: " + episode.title +" with size: " + f"{part.size / (1024 ** 2):.2f} MB ")
total_size += part.size
print(f"Show: {item.title}")
print(f"Total size: {total_size / (1024 ** 3):.2f}")
##download Now
# --- Set download directory ---
download_dir = os.path.expanduser(f"/media/joedoe/SSDdata/TVshows/{item.title}")
os.makedirs(download_dir, exist_ok=True)
downloaded_files = item.download(download_dir, keep_original_name=False,subfolders=True)
print(datetime.now().isoformat() + " ✅ Download complete!: "+ item.title)
for f in downloaded_files:
print("📁", f)
print(datetime.now().isoformat() + " ________END SCRIPT ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment