python3-discogs-client 2.7.1__py3-none-any.whl → 2.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- discogs_client/__init__.py +1 -1
- discogs_client/client.py +11 -0
- discogs_client/models.py +58 -14
- {python3_discogs_client-2.7.1.dist-info → python3_discogs_client-2.9.dist-info}/METADATA +14 -5
- python3_discogs_client-2.9.dist-info/RECORD +11 -0
- {python3_discogs_client-2.7.1.dist-info → python3_discogs_client-2.9.dist-info}/WHEEL +1 -1
- python3_discogs_client-2.7.1.dist-info/RECORD +0 -11
- {python3_discogs_client-2.7.1.dist-info → python3_discogs_client-2.9.dist-info/licenses}/LICENSE +0 -0
- {python3_discogs_client-2.7.1.dist-info → python3_discogs_client-2.9.dist-info}/top_level.txt +0 -0
discogs_client/__init__.py
CHANGED
discogs_client/client.py
CHANGED
|
@@ -19,6 +19,7 @@ class Client:
|
|
|
19
19
|
self.user_agent = user_agent
|
|
20
20
|
self.verbose = False
|
|
21
21
|
self._fetcher = RequestsFetcher()
|
|
22
|
+
self._trust_per_page = True # Default: True
|
|
22
23
|
|
|
23
24
|
if consumer_key and consumer_secret:
|
|
24
25
|
self.set_consumer_key(consumer_key, consumer_secret)
|
|
@@ -219,3 +220,13 @@ class Client:
|
|
|
219
220
|
"""
|
|
220
221
|
self._fetcher.connect_timeout = connect
|
|
221
222
|
self._fetcher.read_timeout = read
|
|
223
|
+
|
|
224
|
+
@property
|
|
225
|
+
def trust_per_page(self) -> bool:
|
|
226
|
+
return self._trust_per_page
|
|
227
|
+
|
|
228
|
+
@trust_per_page.setter
|
|
229
|
+
def trust_per_page(self, value: bool) -> None:
|
|
230
|
+
if not isinstance(value, bool):
|
|
231
|
+
raise ValueError("trust_per_page must be a bool")
|
|
232
|
+
self._trust_per_page = value
|
discogs_client/models.py
CHANGED
|
@@ -354,18 +354,42 @@ class BasePaginatedResponse:
|
|
|
354
354
|
return item
|
|
355
355
|
|
|
356
356
|
def __getitem__(self, index):
|
|
357
|
-
|
|
358
|
-
offset = index % self.per_page
|
|
357
|
+
"""Retrieve an item by its index.
|
|
359
358
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
359
|
+
By default, uses the API's ``per_page`` value to calculate the page
|
|
360
|
+
containing the item directly. If the API returns fewer items per page
|
|
361
|
+
than reported, this may yield incorrect results — set
|
|
362
|
+
``client.trust_per_page = False`` to fall back to a sequential page
|
|
363
|
+
walk at the cost of performance.
|
|
364
|
+
"""
|
|
365
|
+
if self.client._trust_per_page:
|
|
366
|
+
page_index = index // self.per_page + 1
|
|
367
|
+
offset = index % self.per_page
|
|
368
|
+
|
|
369
|
+
try:
|
|
370
|
+
page = self.page(page_index)
|
|
371
|
+
except HTTPError as e:
|
|
372
|
+
if e.status_code == 404:
|
|
373
|
+
raise IndexError(e.msg) from e
|
|
374
|
+
raise
|
|
375
|
+
|
|
376
|
+
return page[offset]
|
|
377
|
+
|
|
378
|
+
# Fallback to sequential page loading if we're not trusting the per_page parameter
|
|
379
|
+
current = 0
|
|
380
|
+
page_index = 1
|
|
381
|
+
while True:
|
|
382
|
+
try:
|
|
383
|
+
page = self.page(page_index)
|
|
384
|
+
except HTTPError as e:
|
|
385
|
+
if e.status_code == 404:
|
|
386
|
+
raise IndexError(e.msg) from e
|
|
366
387
|
raise
|
|
388
|
+
if current + len(page) > index:
|
|
389
|
+
return page[index - current]
|
|
390
|
+
current += len(page)
|
|
391
|
+
page_index += 1
|
|
367
392
|
|
|
368
|
-
return page[offset]
|
|
369
393
|
|
|
370
394
|
def __len__(self):
|
|
371
395
|
return self.count
|
|
@@ -745,7 +769,7 @@ class CollectionFolder(PrimaryAPIObject):
|
|
|
745
769
|
count = SimpleField() #:
|
|
746
770
|
|
|
747
771
|
def __init__(self, client, dict_):
|
|
748
|
-
super(
|
|
772
|
+
super().__init__(client, dict_)
|
|
749
773
|
|
|
750
774
|
@property
|
|
751
775
|
def releases(self):
|
|
@@ -754,14 +778,34 @@ class CollectionFolder(PrimaryAPIObject):
|
|
|
754
778
|
|
|
755
779
|
def add_release(self, release):
|
|
756
780
|
release_id = release.id if isinstance(release, Release) else release
|
|
757
|
-
|
|
758
|
-
self.client._post(
|
|
781
|
+
resource_url = self.fetch('resource_url')
|
|
782
|
+
self.client._post(f"{resource_url}/releases/{release_id}", None)
|
|
759
783
|
|
|
760
784
|
def remove_release(self, instance):
|
|
785
|
+
"""Remove a collection item entirely.
|
|
786
|
+
"""
|
|
761
787
|
if not isinstance(instance, CollectionItemInstance):
|
|
762
788
|
raise TypeError('instance must be of type CollectionItemInstance')
|
|
763
|
-
|
|
764
|
-
self.client._delete(
|
|
789
|
+
resource_url = self.fetch('resource_url')
|
|
790
|
+
self.client._delete(f"{resource_url}/releases/{instance.id}/instances/{instance.instance_id}")
|
|
791
|
+
|
|
792
|
+
def move_release(self, instance, target_folder_id):
|
|
793
|
+
"""Move a collection item to another folder.
|
|
794
|
+
|
|
795
|
+
Moving to folder id 1 moves to the "Uncategorized" folder.
|
|
796
|
+
"""
|
|
797
|
+
if not isinstance(instance, CollectionItemInstance):
|
|
798
|
+
raise TypeError('instance must be of type CollectionItemInstance')
|
|
799
|
+
resource_url = self.fetch('resource_url')
|
|
800
|
+
self.client._post(
|
|
801
|
+
f"{resource_url}/releases/{instance.id}/instances/{instance.instance_id}",
|
|
802
|
+
{"folder_id": target_folder_id},
|
|
803
|
+
)
|
|
804
|
+
|
|
805
|
+
def uncategorize_release(self, instance):
|
|
806
|
+
"""Move a collection item to the "Uncategorized" folder.
|
|
807
|
+
"""
|
|
808
|
+
self.move_release(instance, 1)
|
|
765
809
|
|
|
766
810
|
def __repr__(self):
|
|
767
811
|
return '<CollectionFolder {0!r} {1!r}>'.format(self.id, self.name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python3-discogs-client
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.9
|
|
4
4
|
Summary: Python API client for Discogs
|
|
5
5
|
Home-page: https://github.com/joalla/discogs_client
|
|
6
6
|
Author: joalla
|
|
@@ -18,8 +18,17 @@ Requires-Dist: requests
|
|
|
18
18
|
Requires-Dist: oauthlib
|
|
19
19
|
Requires-Dist: python-dateutil
|
|
20
20
|
Provides-Extra: docs
|
|
21
|
-
Requires-Dist: sphinx
|
|
22
|
-
Requires-Dist: pydata-sphinx-theme
|
|
23
|
-
Requires-Dist: myst-parser
|
|
21
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
22
|
+
Requires-Dist: pydata-sphinx-theme; extra == "docs"
|
|
23
|
+
Requires-Dist: myst-parser; extra == "docs"
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: author-email
|
|
26
|
+
Dynamic: classifier
|
|
27
|
+
Dynamic: description
|
|
28
|
+
Dynamic: home-page
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
Dynamic: provides-extra
|
|
31
|
+
Dynamic: requires-dist
|
|
32
|
+
Dynamic: summary
|
|
24
33
|
|
|
25
34
|
This is an active fork of the official "Discogs API client for Python", which was deprecated by discogs.com as of June 2020. We think it is a very useful Python module and decided to continue maintaining it. Please visit: https://github.com/joalla/discogs_client for more information.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
discogs_client/__init__.py,sha256=9Giuys_-iyNRMOCDQGMjw69NXHC79Ky-CozAeJx7dBE,445
|
|
2
|
+
discogs_client/client.py,sha256=2iSw-t7R0uo_Wc3nYOTs8ELgRjtytpO1L33l4KN3Fyk,7991
|
|
3
|
+
discogs_client/exceptions.py,sha256=7kHj2wbpfT0gLE7uqm6c4aS28Wkr58f6u9jfpcT_NSM,1323
|
|
4
|
+
discogs_client/fetchers.py,sha256=D8npYWt9FILSRIhVsUdA6N0pzRCEUFh5hqQbnBu4IUg,11964
|
|
5
|
+
discogs_client/models.py,sha256=aG0hswHJWP3nrA-j5bSUiyFx5-tih2jtHQDRF8GP1l8,33532
|
|
6
|
+
discogs_client/utils.py,sha256=r0Hh8JHu8T3XZciEg0mAVV_fN7aZhUZIB08CBY5jJMM,3515
|
|
7
|
+
python3_discogs_client-2.9.dist-info/licenses/LICENSE,sha256=GvYq7dzLVxNCGN29xn0Ec1JMpzZwPXzOAdtZsuB9pUI,1455
|
|
8
|
+
python3_discogs_client-2.9.dist-info/METADATA,sha256=MLp4-CLimlOVBUEfsh4FjOMu6my0vCjr8Tt3dgen9rg,1267
|
|
9
|
+
python3_discogs_client-2.9.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
10
|
+
python3_discogs_client-2.9.dist-info/top_level.txt,sha256=jgqsRXqG3dJuCOSykXhXN68DMNu77XYQuqgqlPSSv1E,15
|
|
11
|
+
python3_discogs_client-2.9.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
discogs_client/__init__.py,sha256=F8H5pGOgcXj6mYUVTcdSDB2D4RMDRCkxkDa9K-kkKRI,447
|
|
2
|
-
discogs_client/client.py,sha256=AqQmwJd54DrAFTnTb4zi1jCefjC6sbISh43FZuYsQ0g,7632
|
|
3
|
-
discogs_client/exceptions.py,sha256=7kHj2wbpfT0gLE7uqm6c4aS28Wkr58f6u9jfpcT_NSM,1323
|
|
4
|
-
discogs_client/fetchers.py,sha256=D8npYWt9FILSRIhVsUdA6N0pzRCEUFh5hqQbnBu4IUg,11964
|
|
5
|
-
discogs_client/models.py,sha256=c6OfCIEPW7HtOpegP3tcdGPtEBTm7adDxWyQzcfe52M,31844
|
|
6
|
-
discogs_client/utils.py,sha256=r0Hh8JHu8T3XZciEg0mAVV_fN7aZhUZIB08CBY5jJMM,3515
|
|
7
|
-
python3_discogs_client-2.7.1.dist-info/LICENSE,sha256=GvYq7dzLVxNCGN29xn0Ec1JMpzZwPXzOAdtZsuB9pUI,1455
|
|
8
|
-
python3_discogs_client-2.7.1.dist-info/METADATA,sha256=K7KOJllZVlacHkNgdH0mxKpX9of5ueTqC2HkOf6Sgb8,1088
|
|
9
|
-
python3_discogs_client-2.7.1.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
10
|
-
python3_discogs_client-2.7.1.dist-info/top_level.txt,sha256=jgqsRXqG3dJuCOSykXhXN68DMNu77XYQuqgqlPSSv1E,15
|
|
11
|
-
python3_discogs_client-2.7.1.dist-info/RECORD,,
|
{python3_discogs_client-2.7.1.dist-info → python3_discogs_client-2.9.dist-info/licenses}/LICENSE
RENAMED
|
File without changes
|
{python3_discogs_client-2.7.1.dist-info → python3_discogs_client-2.9.dist-info}/top_level.txt
RENAMED
|
File without changes
|