Skip to content

Commit

Permalink
v0.3.8
Browse files Browse the repository at this point in the history
Multiple overdue bug fixes
  • Loading branch information
github-actions[bot] committed Nov 29, 2022
1 parent 02d8ae7 commit fc0a029
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 167 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Changelog
*********

v0.3.8
========================================

- Fix scrobbling for #58
- add images for single track lookup
- widen ytmusicapi version reqs to >= 0.22, < 0.30
- Quick hack for #67
- update ytmusicapi version
- Merge pull request #69 from fatg3erman/feature/browse-album
- Album lookups always return information that is at least as complete, and usually more so, that anything we may already have from search. So when we parsing those results we should always replace any information we already have cached.
- Add uri search parameter to permit browsing of album Uris

v0.3.7
========================================

Expand Down
14 changes: 8 additions & 6 deletions mopidy_ytmusic/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,18 @@ def _get_auto_playlists(self):
def scrobble_track(self, bId):
# Called through YTMusicScrobbleListener
# Let YTMusic know we're playing this track so it will be added to our history.
CPN_ALPHABET = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_")
CPN_ALPHABET = (
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
)
cpn = "".join(
(
CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(0, 16)
)
(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(0, 16))
)
player_response = self.api._send_request(
"player",
{
"playbackContext": {
"contentPlaybackContext": {
"signatureTimestamp": self.playback.signatureTimestamp,
"signatureTimestamp": self.playback.signatureTimestamp,
},
},
"videoId": bId,
Expand All @@ -185,7 +185,9 @@ def scrobble_track(self, bId):
"c": "WEB_REMIX",
}
tr = requests.get(
player_response["playbackTracking"]["videostatsPlaybackUrl"]["baseUrl"],
player_response["playbackTracking"]["videostatsPlaybackUrl"][
"baseUrl"
],
params=params,
headers=self.api.headers,
proxies=self.api.proxies,
Expand Down
46 changes: 23 additions & 23 deletions mopidy_ytmusic/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,9 @@ def search(self, query=None, uris=None, exact=False):
" ".join(query["album"]),
)
elif "uri" in query:
uri = query['uri'][0]
uri = query["uri"][0]
tracks = []
if uri.startswith('ytmusic:album:'):
if uri.startswith("ytmusic:album:"):
bId, upload = parse_uri(uri)
if upload:
try:
Expand Down Expand Up @@ -967,27 +967,27 @@ def albumToTracks(self, album, bId):
return ret

def getTrack(self, bId):
if bId not in self.TRACKS:
track = self.backend.api.get_song(bId)
tv = track['videoDetails']
self.TRACKS[bId] = Track(
uri=f"ytmusic:track:{bId}",
name=tv['title'],
artists=[Artist(name=tv['author'])],
album=None,
composers=[],
performers=[],
genre="",
track_no=None,
date=None,
length=(int(tv["lengthSeconds"]) * 1000),
bitrate=0,
comment="",
musicbrainz_id="",
last_modified=None,
)
self.addThumbnails(bId, tv['thumbnail'])
return self.TRACKS[bId]
if bId not in self.TRACKS:
track = self.backend.api.get_song(bId)
tv = track["videoDetails"]
self.TRACKS[bId] = Track(
uri=f"ytmusic:track:{bId}",
name=tv["title"],
artists=[Artist(name=tv["author"])],
album=None,
composers=[],
performers=[],
genre="",
track_no=None,
date=None,
length=(int(tv["lengthSeconds"]) * 1000),
bitrate=0,
comment="",
musicbrainz_id="",
last_modified=None,
)
self.addThumbnails(bId, tv["thumbnail"])
return self.TRACKS[bId]

def parseSearch(self, results, field=None, queries=[]):
tracks = set()
Expand Down
Loading

0 comments on commit fc0a029

Please sign in to comment.