Skip to content

Commit

Permalink
Fix scrobbling for #58
Browse files Browse the repository at this point in the history
  • Loading branch information
impliedchaos committed Nov 29, 2022
1 parent dbc957a commit 02d8ae7
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions mopidy_ytmusic/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,37 +161,31 @@ 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 = "".join(
(
CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(0, 16)
)
)
player_response = self.api._send_request(
"player",
{
"playbackContext": {
"contentPlaybackContext": {"signatureTimestamp": 18766}
"contentPlaybackContext": {
"signatureTimestamp": self.playback.signatureTimestamp,
},
},
"video_id": bId,
"videoId": bId,
"cpn": cpn,
},
)
trackurl = re.sub(
r"plid=",
"list=",
player_response["playbackTracking"]["videostatsPlaybackUrl"][
"baseUrl"
],
)
CPN_ALPHABET = (
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
)
params = {
"cpn": "".join(
(
CPN_ALPHABET[random.randint(0, 256) & 63]
for _ in range(0, 16)
)
),
"referrer": "https://music.youtube.com",
"cpn": cpn,
"ver": 2,
"c": "WEB_REMIX",
}
tr = requests.get(
trackurl,
player_response["playbackTracking"]["videostatsPlaybackUrl"]["baseUrl"],
params=params,
headers=self.api.headers,
proxies=self.api.proxies,
Expand Down

0 comments on commit 02d8ae7

Please sign in to comment.