Skip to content

Commit

Permalink
Merge pull request #752 from meisnate12/nightly
Browse files Browse the repository at this point in the history
add url_theme and file_theme and bug fixes
  • Loading branch information
meisnate12 authored Mar 6, 2022
2 parents 46c02f1 + 457c52a commit 89754dc
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 15 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Docker Nightly Release

on:
push:
branches: [ nightly ]
pull_request:
branches: [ nightly ]

jobs:

docker-develop:
runs-on: ubuntu-latest

steps:

- name: Check Out Repo
uses: actions/checkout@v2
with:
ref: nightly

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/plex-meta-manager:nightly
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.15.1-develop91
1.15.1-develop94
4 changes: 4 additions & 0 deletions config/config.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ tautulli: # Can be individually specified
apikey: ################################
omdb:
apikey: ########
cache_expiration: 60
mdblist:
apikey: #########################
cache_expiration: 60
notifiarr:
apikey: ####################################
anidb: # Not required for AniDB builders unless you want mature content
Expand Down
18 changes: 15 additions & 3 deletions modules/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"delete_not_scheduled", "tmdb_person", "build_collection", "collection_order", "collection_level",
"validate_builders", "libraries", "sync_to_users", "collection_name", "playlist_name", "name", "blank_collection"
]
details = ["ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_mode", "limit",
details = ["ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_mode", "limit", "url_theme", "file_theme"
"minimum_items", "label", "album_sorting", "cache_builders"] + boolean_details + scheduled_boolean + string_details
collectionless_details = ["collection_order", "plex_collectionless", "label", "label_sync_mode", "test"] + \
poster_details + background_details + summary_details + string_details
Expand Down Expand Up @@ -183,7 +183,8 @@
parts_collection_valid = [
"filters", "plex_all", "plex_search", "trakt_list", "trakt_list_details", "collection_mode", "label", "visible_library", "limit",
"visible_home", "visible_shared", "show_missing", "save_missing", "missing_only_released", "server_preroll", "changes_webhooks",
"item_lock_background", "item_lock_poster", "item_lock_title", "item_refresh", "item_refresh_delay", "imdb_list", "cache_builders"
"item_lock_background", "item_lock_poster", "item_lock_title", "item_refresh", "item_refresh_delay", "imdb_list", "cache_builders",
"url_theme", "file_theme"
] + episode_parts_only + summary_details + poster_details + background_details + string_details
playlist_attributes = [
"filters", "name_mapping", "show_filtered", "show_missing", "save_missing",
Expand Down Expand Up @@ -766,6 +767,13 @@ def _background(self, method_name, method_data):
logger.error(f"{self.Type} Error: Background Path Does Not Exist: {os.path.abspath(method_data)}")

def _details(self, method_name, method_data, method_final, methods):
if method_name == "url_theme":
self.url_theme = method_data
elif method_name == "file_theme":
if os.path.exists(os.path.abspath(method_data)):
self.file_theme = os.path.abspath(method_data)
else:
logger.error(f"{self.Type} Error: Theme Path Does Not Exist: {os.path.abspath(method_data)}")
if method_name == "collection_mode":
self.details[method_name] = util.check_collection_mode(method_data)
elif method_name == "minimum_items":
Expand Down Expand Up @@ -2393,7 +2401,6 @@ def get_summary(summary_method, summaries):
sync_tags = self.details["label.sync"] if "label.sync" in self.details else None
self.library.edit_tags("label", self.obj, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags)


poster_image = None
background_image = None
asset_location = None
Expand Down Expand Up @@ -2487,6 +2494,11 @@ def get_summary(summary_method, summaries):
if self.collection_poster or self.collection_background:
self.library.upload_images(self.obj, poster=self.collection_poster, background=self.collection_background)

if self.url_theme:
self.library.upload_theme(url=self.url_theme)
elif self.file_theme:
self.library.upload_theme(filepath=self.file_theme)

def sort_collection(self):
logger.info("")
logger.separator(f"Sorting {self.name} {self.Type}", space=False, border=False)
Expand Down
7 changes: 7 additions & 0 deletions modules/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,13 @@ def get_all(self, collection_level=None, load=False):
self._all_items = results
return results

def upload_theme(self, collection, url=None, filepath=None):
key = f"/library/metadata/{collection.ratingKey}/themes"
if url:
self.PlexServer.query(f"{key}?url={parse.quote_plus(url)}", method=self.PlexServer._session.post)
elif filepath:
self.PlexServer.query(key, method=self.PlexServer._session.post, data=open(filepath, 'rb').read())

@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
def create_playlist(self, name, items):
return self.PlexServer.createPlaylist(name, items=items)
Expand Down
2 changes: 1 addition & 1 deletion modules/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _user_recommendations(self, amount, is_movie):
raise Failed(f"Trakt Error: failed to fetch {media_type} Recommendations")
if len(items) == 0:
raise Failed(f"Trakt Error: no {media_type} Recommendations were found")
return self._parse(items, item_type="movie" if is_movie else "show")
return self._parse(items, typeless=True, item_type="movie" if is_movie else "show")

def _pagenation(self, pagenation, amount, is_movie):
items = self._request(f"/{'movies' if is_movie else 'shows'}/{pagenation}?limit={amount}")
Expand Down
16 changes: 6 additions & 10 deletions plex_meta_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,10 @@ def library_operations(config, library):
num_edited = 0
for i, item in enumerate(tracks, 1):
logger.ghost(f"Processing Track: {i}/{len(tracks)} {item.title}")
try:
if not item.title and item.titleSort:
library.edit_query(item, {"title.locked": 1, "title.value": item.titleSort})
num_edited += 1
logger.info(f"Track: {item.titleSort} was updated with sort title")
except Failed as e:
logger.error(e)
if not item.title and item.titleSort:
library.edit_query(item, {"title.locked": 1, "title.value": item.titleSort})
num_edited += 1
logger.info(f"Track: {item.titleSort} was updated with sort title")
logger.info(f"{len(tracks)} Tracks Processed; {num_edited} Blank Track Titles Updated")

tmdb_collections = {}
Expand Down Expand Up @@ -701,9 +698,8 @@ def get_rating(attribute):
logger.info("")
unmanaged_collections = []
for col in library.get_all_collections():
if (library.delete_collections_with_less is not None
and (library.delete_collections_with_less == 0 or col.childCount < library.delete_collections_with_less)) \
or (col.title not in library.collections and library.delete_unmanaged_collections):
if (library.delete_collections_with_less and col.childCount < library.delete_collections_with_less) \
or (library.delete_unmanaged_collections and col.title not in library.collections):
library.query(col.delete)
logger.info(f"{col.title} Deleted")
elif col.title not in library.collections:
Expand Down

0 comments on commit 89754dc

Please sign in to comment.