mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-15 04:03:59 +00:00
Move collection related code to new add_release_to_user_collections()
- it simplifies imports - it will ease creation of unit tests - outputs a debug line when it happens
This commit is contained in:
@@ -34,7 +34,7 @@ from picard.ui.item import Item
|
||||
from picard.util import format_time, mbid_validate
|
||||
from picard.util.textencoding import asciipunct
|
||||
from picard.cluster import Cluster
|
||||
from picard.collection import Collection, user_collections
|
||||
from picard.collection import add_release_to_user_collections
|
||||
from picard.mbxml import (
|
||||
release_group_to_metadata,
|
||||
release_to_metadata,
|
||||
@@ -140,15 +140,7 @@ class Album(DataObject, Item):
|
||||
m['totaldiscs'] = release_node.medium_list[0].count
|
||||
|
||||
# Add album to collections
|
||||
if "collection_list" in release_node.children:
|
||||
# Check for empty collection list
|
||||
if "collection" in release_node.collection_list[0].children:
|
||||
for node in release_node.collection_list[0].collection:
|
||||
if node.editor[0].text.lower() == config.persist["oauth_username"].lower():
|
||||
if node.id not in user_collections:
|
||||
user_collections[node.id] = \
|
||||
Collection(node.id, node.name[0].text, node.release_list[0].count)
|
||||
user_collections[node.id].releases.add(self.id)
|
||||
add_release_to_user_collections(release_node)
|
||||
|
||||
# Run album metadata plugins
|
||||
try:
|
||||
|
||||
@@ -131,3 +131,19 @@ def load_user_collections(callback=None):
|
||||
tagger.xmlws.get_collection_list(partial(request_finished))
|
||||
else:
|
||||
user_collections.clear()
|
||||
|
||||
|
||||
def add_release_to_user_collections(release_node):
|
||||
# Add album to collections
|
||||
if "collection_list" in release_node.children:
|
||||
# Check for empty collection list
|
||||
if "collection" in release_node.collection_list[0].children:
|
||||
username = config.persist["oauth_username"].lower()
|
||||
for node in release_node.collection_list[0].collection:
|
||||
if node.editor[0].text.lower() == username:
|
||||
if node.id not in user_collections:
|
||||
user_collections[node.id] = \
|
||||
Collection(node.id, node.name[0].text, node.release_list[0].count)
|
||||
user_collections[node.id].releases.add(release_node.id)
|
||||
log.debug("Adding release %r to %r" %
|
||||
(release_node.id, user_collections[node.id]))
|
||||
|
||||
Reference in New Issue
Block a user