Last active
December 29, 2023 01:40
-
-
Save JonnyWong16/a38617c70fe1e43a6b93183e67c62cad to your computer and use it in GitHub Desktop.
Downloads all photo thumbnails recursively for a photo album in Plex.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
from plexapi.server import PlexServer | |
from plexapi.utils import download | |
# Replace with your Plex information | |
PLEX_URL = 'http://localhost:32400' | |
PLEX_TOKEN = 'XXXXXXXXXXXXXXXXXXXX' | |
PLEX_LIBRARY_NAME = 'Photos' | |
PLEX_ALBUM_NAME = 'iPHONE' | |
def download_photo_thumbnails(album, root_path=''): | |
savepath = os.path.join(root_path, album.title) | |
print(f'Downloading photo thumbnails from album: {savepath}') | |
for photo in album.photos(): | |
download( | |
url=plex.url(photo.thumb, includeToken=True), | |
token=PLEX_TOKEN, | |
filename=photo.title, | |
savepath=savepath, | |
showstatus=True | |
) | |
for _album in album.albums(): | |
download_photo_thumbnails( | |
_album, | |
root_path=savepath | |
) | |
if __name__ == "__main__": | |
plex = PlexServer(PLEX_URL, PLEX_TOKEN) | |
library = plex.library.section(PLEX_LIBRARY_NAME) | |
album = library.get(PLEX_ALBUM_NAME) | |
download_photo_thumbnails(album) | |
print("Done.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment