Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #40 from metabrainz/update-deps
Browse files Browse the repository at this point in the history
Update deps
  • Loading branch information
mayhem authored Jan 26, 2024
2 parents 2b90b5e + af9483e commit c11d951
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
27 changes: 27 additions & 0 deletions lb_content_resolver/py_sonic_fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from libsonic import Connection


class FixedConnection(Connection):
"""
This hack enables album ids to strings -- a PR has been submitted, but in case
it doesn't get accepted in a timely manner, this workaround allows us to
continue.
"""

def getAlbumInfo2(self, aid):
"""
since 1.14.0
Same as getAlbumInfo, but uses ID3 tags
aid:int The album ID
"""
methodName = 'getAlbumInfo2'
viewName = '%s.view' % methodName

# The release version has an int() cast here
q = {'id': aid}
req = self._getRequest(viewName, q)
res = self._doInfoReq(req)
self._checkStatus(res)
return res
6 changes: 3 additions & 3 deletions lb_content_resolver/subsonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import sys
from uuid import UUID

import libsonic
import peewee
from tqdm import tqdm

from lb_content_resolver.database import Database
from lb_content_resolver.model.database import db
from lb_content_resolver.model.recording import Recording, FileIdType
from lb_content_resolver.utils import bcolors
from lb_content_resolver.py_sonic_fix import FixedConnection


class SubsonicDatabase(Database):
Expand Down Expand Up @@ -48,7 +48,7 @@ def connect(self):

print("[ connect to subsonic ]")

return libsonic.Connection(
return FixedConnection(
self.config.SUBSONIC_HOST,
self.config.SUBSONIC_USER,
self.config.SUBSONIC_PASSWORD,
Expand Down Expand Up @@ -94,7 +94,7 @@ def run_sync(self):
# Some servers might already include the MBID in the list or album response
album_mbid = album_info.get("musicBrainzId", album.get("musicBrainzId"))
if not album_mbid:
album_info2 = conn.getAlbumInfo2(id=album["id"])
album_info2 = conn.getAlbumInfo2(aid=album["id"])
try:
album_mbid = album_info2["albumInfo"]["musicBrainzId"]
except KeyError:
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ nmslib==2.1.1
regex==2023.6.3
lb_matching_tools@git+https://github.com/metabrainz/listenbrainz-matching-tools.git@v-2023-07-19.0
requests
py-sonic@git+https://github.com/mayhem/py-sonic.git@int-vs-string
py-sonic==1.0.0
tqdm
troi@git+https://github.com/metabrainz/troi-recommendation-playground.git@lb-local
icecream
troi==2024.1.26.0

0 comments on commit c11d951

Please sign in to comment.