Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into debug_replies
Browse files Browse the repository at this point in the history
  • Loading branch information
zas committed Apr 7, 2024
2 parents 8aa7bb2 + 58c1177 commit 677f776
Show file tree
Hide file tree
Showing 64 changed files with 5,283 additions and 4,956 deletions.
18 changes: 10 additions & 8 deletions picard/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Copyright (C) 2014, 2017 Sophist-UK
# Copyright (C) 2014, 2017-2021, 2023-2024 Laurent Monin
# Copyright (C) 2016-2017 Sambhav Kothari
# Copyright (C) 2019, 2021-2022 Philipp Wolfer
# Copyright (C) 2019, 2021-2022, 2024 Philipp Wolfer
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -30,19 +30,21 @@

from picard import log
from picard.config import get_config
from picard.webservice.api_helpers import MBAPIHelper


user_collections = {}


class Collection(QtCore.QObject):

def __init__(self, collection_id):
def __init__(self, collection_id: str, mb_api: MBAPIHelper):
self.id = collection_id
self.name = ''
self.size = 0
self.pending_releases = set()
self.releases = set()
self._mb_api = mb_api

@property
def size(self):
Expand All @@ -63,12 +65,12 @@ def _modify(self, api_method, success_handler, releases, callback):
api_method(self.id, list(releases), when_done)

def add_releases(self, releases, callback):
api_method = self.tagger.mb_api.put_to_collection
self._modify(api_method, self._success_add, releases, callback)
api_method = self._mb_api.put_to_collection
self._modify(api_method, self._success_add, set(releases), callback)

def remove_releases(self, releases, callback):
api_method = self.tagger.mb_api.delete_from_collection
self._modify(api_method, self._success_remove, releases, callback)
api_method = self._mb_api.delete_from_collection
self._modify(api_method, self._success_remove, set(releases), callback)

def _finished(self, success_handler, releases, callback, document, reply, error):
self.pending_releases -= releases
Expand Down Expand Up @@ -116,7 +118,7 @@ def _success(self, count, callback, status_msg, debug_msg):
def get_user_collection(collection_id):
collection = user_collections.get(collection_id)
if collection is None:
collection = user_collections[collection_id] = Collection(collection_id)
collection = user_collections[collection_id] = Collection(collection_id, QtCore.QObject.tagger.mb_api)
return collection


Expand Down Expand Up @@ -161,7 +163,7 @@ def request_finished(document, reply, error):

def add_release_to_user_collections(release_node):
"""Add album to collections"""
# Check for empy collection list
# Check for empty collection list
if 'collections' in release_node:
release_id = release_node['id']
config = get_config()
Expand Down
2 changes: 1 addition & 1 deletion picard/script/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ def func_is_audio(parser):
@script_function(documentation=N_(
"""`$is_video()`
Returns true, if the file processed is an video file.
Returns true, if the file processed is a video file.
_Since Picard 2.2_"""
))
Expand Down
Loading

0 comments on commit 677f776

Please sign in to comment.