deezer-python-gql 0.19.0__py3-none-any.whl → 0.20.0__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.
@@ -123,6 +123,9 @@ class DeezerBaseClient:
123
123
  :param url: GraphQL endpoint URL (defaults to Pipe API).
124
124
  :param session: Optional pre-configured aiohttp.ClientSession.
125
125
  If provided, the caller is responsible for closing it.
126
+ :param account_id: Optional Deezer Family profile to act as. A profile has no
127
+ ARL of its own; it signs in with the ARL of the Family admin. Only profiles
128
+ that ``get_family()`` marks as ``isLoggableAs`` can be used.
126
129
  """
127
130
 
128
131
  PIPE_URL = "https://pipe.deezer.com/api"
@@ -136,9 +139,11 @@ class DeezerBaseClient:
136
139
  arl: str,
137
140
  url: str = PIPE_URL,
138
141
  session: ClientSession | None = None,
142
+ account_id: str | None = None,
139
143
  ) -> None:
140
144
  self.url = url
141
145
  self._arl = arl
146
+ self._account_id = account_id
142
147
  self._session = session
143
148
  self._owns_session = session is None
144
149
  # An external session may be shared by clients for different Deezer accounts.
@@ -347,12 +352,18 @@ class DeezerBaseClient:
347
352
 
348
353
  logger.debug("JWT expired or missing, refreshing from ARL")
349
354
  params = {"jo": "p", "rto": "c", "i": "c"}
355
+ body = None
356
+ if self._account_id:
357
+ # A Family profile signs in with the admin's ARL and its own id
358
+ params["i"] = "p"
359
+ body = {"arl": self._arl, "account_id": self._account_id}
350
360
 
351
361
  session = self._get_session()
352
362
  async with session.post(
353
363
  self.AUTH_URL,
354
364
  params=params,
355
365
  cookies=self._request_cookies(self.AUTH_URL, include_arl=True),
366
+ json=body,
356
367
  timeout=ClientTimeout(total=10),
357
368
  ) as resp:
358
369
  self._store_cookies(resp)
@@ -383,6 +394,10 @@ class DeezerBaseClient:
383
394
  msg = "Unexpected response from auth.deezer.com (invalid or missing JWT)"
384
395
  raise GraphQLClientAuthError(msg) from exc
385
396
 
397
+ if self._account_id and str(payload.get("userId")) != self._account_id:
398
+ msg = f"auth.deezer.com did not sign in as Family profile {self._account_id}"
399
+ raise GraphQLClientAuthError(msg)
400
+
386
401
  self._jwt = jwt
387
402
  self._jwt_expires_at = expires_at
388
403
  logger.debug("JWT acquired, expires at %s", self._jwt_expires_at)
@@ -86,6 +86,8 @@ from .fragments import (
86
86
  AudiobookFieldsContributorsEdges,
87
87
  AudiobookFieldsContributorsEdgesNodeArtist,
88
88
  AudiobookFieldsCover,
89
+ FamilyProfileFields,
90
+ FamilyProfileFieldsPermissions,
89
91
  LivestreamFields,
90
92
  LivestreamFieldsCover,
91
93
  LivestreamFieldsMedia,
@@ -205,6 +207,13 @@ from .get_charts import (
205
207
  GetChartsChartsCountryTracksEdgesNode,
206
208
  GetChartsChartsCountryTracksPageInfo,
207
209
  )
210
+ from .get_family import (
211
+ GetFamily,
212
+ GetFamilyMe,
213
+ GetFamilyMeFamily,
214
+ GetFamilyMeFamilyLinked,
215
+ GetFamilyMeFamilyMain,
216
+ )
208
217
  from .get_favorite_albums import (
209
218
  GetFavoriteAlbums,
210
219
  GetFavoriteAlbumsMe,
@@ -759,6 +768,8 @@ __all__ = [
759
768
  "DeletePlaylistDeletePlaylist",
760
769
  "DiscoveryTuner",
761
770
  "DiscoveryTunerInput",
771
+ "FamilyProfileFields",
772
+ "FamilyProfileFieldsPermissions",
762
773
  "GetAlbum",
763
774
  "GetAlbumAlbum",
764
775
  "GetAlbumAlbumFallback",
@@ -837,6 +848,11 @@ __all__ = [
837
848
  "GetChartsChartsCountryTracksEdges",
838
849
  "GetChartsChartsCountryTracksEdgesNode",
839
850
  "GetChartsChartsCountryTracksPageInfo",
851
+ "GetFamily",
852
+ "GetFamilyMe",
853
+ "GetFamilyMeFamily",
854
+ "GetFamilyMeFamilyLinked",
855
+ "GetFamilyMeFamilyMain",
840
856
  "GetFavoriteAlbums",
841
857
  "GetFavoriteAlbumsMe",
842
858
  "GetFavoriteAlbumsMeUserFavorites",
@@ -125,6 +125,9 @@ class DeezerBaseClient:
125
125
  :param url: GraphQL endpoint URL (defaults to Pipe API).
126
126
  :param session: Optional pre-configured aiohttp.ClientSession.
127
127
  If provided, the caller is responsible for closing it.
128
+ :param account_id: Optional Deezer Family profile to act as. A profile has no
129
+ ARL of its own; it signs in with the ARL of the Family admin. Only profiles
130
+ that ``get_family()`` marks as ``isLoggableAs`` can be used.
128
131
  """
129
132
 
130
133
  PIPE_URL = "https://pipe.deezer.com/api"
@@ -138,9 +141,11 @@ class DeezerBaseClient:
138
141
  arl: str,
139
142
  url: str = PIPE_URL,
140
143
  session: ClientSession | None = None,
144
+ account_id: str | None = None,
141
145
  ) -> None:
142
146
  self.url = url
143
147
  self._arl = arl
148
+ self._account_id = account_id
144
149
  self._session = session
145
150
  self._owns_session = session is None
146
151
  # An external session may be shared by clients for different Deezer accounts.
@@ -349,12 +354,18 @@ class DeezerBaseClient:
349
354
 
350
355
  logger.debug("JWT expired or missing, refreshing from ARL")
351
356
  params = {"jo": "p", "rto": "c", "i": "c"}
357
+ body = None
358
+ if self._account_id:
359
+ # A Family profile signs in with the admin's ARL and its own id
360
+ params["i"] = "p"
361
+ body = {"arl": self._arl, "account_id": self._account_id}
352
362
 
353
363
  session = self._get_session()
354
364
  async with session.post(
355
365
  self.AUTH_URL,
356
366
  params=params,
357
367
  cookies=self._request_cookies(self.AUTH_URL, include_arl=True),
368
+ json=body,
358
369
  timeout=ClientTimeout(total=10),
359
370
  ) as resp:
360
371
  self._store_cookies(resp)
@@ -385,6 +396,10 @@ class DeezerBaseClient:
385
396
  msg = "Unexpected response from auth.deezer.com (invalid or missing JWT)"
386
397
  raise GraphQLClientAuthError(msg) from exc
387
398
 
399
+ if self._account_id and str(payload.get("userId")) != self._account_id:
400
+ msg = f"auth.deezer.com did not sign in as Family profile {self._account_id}"
401
+ raise GraphQLClientAuthError(msg)
402
+
388
403
  self._jwt = jwt
389
404
  self._jwt_expires_at = expires_at
390
405
  logger.debug("JWT acquired, expires at %s", self._jwt_expires_at)
@@ -65,6 +65,7 @@ from .get_audiobook_chapter import (
65
65
  from .get_banned_artists import GetBannedArtists, GetBannedArtistsMe
66
66
  from .get_banned_tracks import GetBannedTracks, GetBannedTracksMe
67
67
  from .get_charts import GetCharts, GetChartsCharts
68
+ from .get_family import GetFamily, GetFamilyMe
68
69
  from .get_favorite_albums import GetFavoriteAlbums, GetFavoriteAlbumsMe
69
70
  from .get_favorite_artists import GetFavoriteArtists, GetFavoriteArtistsMe
70
71
  from .get_favorite_audiobooks import GetFavoriteAudiobooks, GetFavoriteAudiobooksMe
@@ -1475,6 +1476,38 @@ class DeezerGQLClient(DeezerBaseClient):
1475
1476
  data = self.get_data(response)
1476
1477
  return GetCharts.model_validate(data).charts
1477
1478
 
1479
+ async def get_family(self, **kwargs: Any) -> Optional[GetFamilyMe]:
1480
+ query = gql("""
1481
+ query GetFamily {
1482
+ me {
1483
+ id
1484
+ family {
1485
+ main {
1486
+ ...FamilyProfileFields
1487
+ }
1488
+ linked {
1489
+ ...FamilyProfileFields
1490
+ }
1491
+ }
1492
+ }
1493
+ }
1494
+
1495
+ fragment FamilyProfileFields on FamilyUser {
1496
+ id
1497
+ name
1498
+ caption
1499
+ permissions {
1500
+ isLoggableAs
1501
+ }
1502
+ }
1503
+ """)
1504
+ variables: dict[str, object] = {}
1505
+ response = await self.execute(
1506
+ query=query, operation_name="GetFamily", variables=variables, **kwargs
1507
+ )
1508
+ data = self.get_data(response)
1509
+ return GetFamily.model_validate(data).me
1510
+
1478
1511
  async def get_favorite_albums(
1479
1512
  self,
1480
1513
  first: Union[Optional[int], UnsetType] = UNSET,
@@ -132,6 +132,17 @@ class AudiobookFieldsContributorsEdgesNodeArtist(BaseModel):
132
132
  name: str
133
133
 
134
134
 
135
+ class FamilyProfileFields(BaseModel):
136
+ id: str
137
+ name: str
138
+ caption: str
139
+ permissions: "FamilyProfileFieldsPermissions"
140
+
141
+
142
+ class FamilyProfileFieldsPermissions(BaseModel):
143
+ is_loggable_as: bool = Field(alias="isLoggableAs")
144
+
145
+
135
146
  class LivestreamFields(BaseModel):
136
147
  id: str
137
148
  name: str
@@ -292,6 +303,7 @@ AlbumFields.model_rebuild()
292
303
  ArtistFields.model_rebuild()
293
304
  AudiobookChapterFields.model_rebuild()
294
305
  AudiobookFields.model_rebuild()
306
+ FamilyProfileFields.model_rebuild()
295
307
  LivestreamFields.model_rebuild()
296
308
  PageInfoFields.model_rebuild()
297
309
  PlaylistFields.model_rebuild()
@@ -0,0 +1,34 @@
1
+ # Generated by ariadne-codegen
2
+ # Source: queries
3
+
4
+ from typing import Optional
5
+
6
+ from .base_model import BaseModel
7
+ from .fragments import FamilyProfileFields
8
+
9
+
10
+ class GetFamily(BaseModel):
11
+ me: Optional["GetFamilyMe"]
12
+
13
+
14
+ class GetFamilyMe(BaseModel):
15
+ id: str
16
+ family: Optional["GetFamilyMeFamily"]
17
+
18
+
19
+ class GetFamilyMeFamily(BaseModel):
20
+ main: "GetFamilyMeFamilyMain"
21
+ linked: list["GetFamilyMeFamilyLinked"]
22
+
23
+
24
+ class GetFamilyMeFamilyMain(FamilyProfileFields):
25
+ pass
26
+
27
+
28
+ class GetFamilyMeFamilyLinked(FamilyProfileFields):
29
+ pass
30
+
31
+
32
+ GetFamily.model_rebuild()
33
+ GetFamilyMe.model_rebuild()
34
+ GetFamilyMeFamily.model_rebuild()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deezer-python-gql
3
- Version: 0.19.0
3
+ Version: 0.20.0
4
4
  Summary: Async typed Python client for Deezer's Pipe GraphQL API.
5
5
  Author-email: Julian Daberkow <jdaberkow@users.noreply.github.com>
6
6
  License: Apache-2.0
@@ -22,7 +22,7 @@ Requires-Dist: pre-commit-hooks==6.0.0; extra == "test"
22
22
  Requires-Dist: pytest==9.1.1; extra == "test"
23
23
  Requires-Dist: pytest-asyncio==1.4.0; extra == "test"
24
24
  Requires-Dist: pytest-cov==7.1.0; extra == "test"
25
- Requires-Dist: ruff==0.16.8; extra == "test"
25
+ Requires-Dist: ruff==0.16.9; extra == "test"
26
26
  Provides-Extra: dev
27
27
  Requires-Dist: ariadne-codegen[subscriptions]; extra == "dev"
28
28
  Dynamic: license-file
@@ -136,6 +136,7 @@ asyncio.run(main())
136
136
  | `get_banned_tracks(first, after)` | Tracks banned from recommendations, with ban date |
137
137
  | `get_banned_artists(first, after)` | Artists banned from recommendations, with ban date |
138
138
  | `get_flow_tuner()` | Flow tuner: `DEFAULT` or `DISCOVERY` |
139
+ | `get_family()` | Deezer Family members, with `isLoggableAs` for usable profiles |
139
140
 
140
141
  ### Music Together (Collaborative Playlists)
141
142
 
@@ -286,6 +287,21 @@ If the ARL is rejected (bad or expired), the client raises
286
287
  `GraphQLClientAuthError` — catch it to prompt for a new ARL instead of retrying.
287
288
  Transient server errors raise `GraphQLClientHttpError` instead.
288
289
 
290
+ ### Deezer Family profiles
291
+
292
+ Profiles of a Deezer Family have no ARL of their own, they share the login of the
293
+ Family admin. Pass `account_id` to act as one of them:
294
+
295
+ ```python
296
+ family = (await client.get_family()).family
297
+ profile = next(m for m in family.linked if m.permissions.is_loggable_as)
298
+ profile_client = DeezerGQLClient(arl="ADMIN_ARL", account_id=profile.id)
299
+ ```
300
+
301
+ Members with their own login (independent accounts) are not loggable, they need their
302
+ own ARL. If Deezer does not sign in as the profile, the client raises
303
+ `GraphQLClientAuthError`.
304
+
289
305
  ## License
290
306
 
291
307
  Apache-2.0
@@ -1,7 +1,7 @@
1
1
  deezer_python_gql/__init__.py,sha256=kwp838G6q8HnV_R0B0zWRBagYXt0rqfXY1IsyX8XDIo,641
2
- deezer_python_gql/base_client.py,sha256=gQkxDs1S9rwL1xMaxivHzVtPE6SeJqlP-oBRdmjb7sc,17160
2
+ deezer_python_gql/base_client.py,sha256=OA2RX34k9pjPqMRL1OPA4NQY-XJi9EppaeJ3_JDu3g0,17973
3
3
  deezer_python_gql/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- deezer_python_gql/generated/__init__.py,sha256=H8hJmF0xuWk4iR1kN-p71MERnThYyoWthsCEGp-8nnI,52131
4
+ deezer_python_gql/generated/__init__.py,sha256=Dk16NK4s3ZUCJNOHGQ7dITkAlPQYDbq3N4Hx4ReSLwM,52517
5
5
  deezer_python_gql/generated/add_album_to_favorite.py,sha256=hprfZkN_jIEl3N_zw962GAL_7XhW6odh_rBldgZ0brM,596
6
6
  deezer_python_gql/generated/add_artist_to_favorite.py,sha256=NU2EKBf3uwBjg5qRvvZWF1GmaHlFzuoDRB1iDFUquI4,574
7
7
  deezer_python_gql/generated/add_audiobook_to_favorite.py,sha256=dKuMxxqmPu9drwV4Ey3bl9O4eBRet_8JniLZG4wK1C8,456
@@ -11,14 +11,14 @@ deezer_python_gql/generated/add_track_to_favorite.py,sha256=EUB2jNV5XzbsqntfS6UZ
11
11
  deezer_python_gql/generated/add_tracks_to_playlist.py,sha256=S_AGBUnOV_YP7zdyYpCxWIeJpBuae-r5VOH8HjDcqeM,933
12
12
  deezer_python_gql/generated/ban_artist_from_recommendation.py,sha256=nn7FVdUCVcyfXN528SxGx13UgXx8EToOos-6NNODrU0,703
13
13
  deezer_python_gql/generated/ban_track_from_recommendation.py,sha256=PTjl-0-bqG-49PqAZVqFpe1kk8z5WvyLMG8Gcp4XOi0,687
14
- deezer_python_gql/generated/base_client.py,sha256=dh7AkMdv6xYqwcToC1RbD5Q-tBv54blJE_WJKIUPjPY,17192
14
+ deezer_python_gql/generated/base_client.py,sha256=VzSudDGtyBB1tUu21nDQqsCyVXtrwWRMmVwkFCqF_Pc,18005
15
15
  deezer_python_gql/generated/base_model.py,sha256=S-phq2fzKu2Kuct1dUnbyvMPT5k7TsfqOkCf_3yZ19I,640
16
16
  deezer_python_gql/generated/bookmark_podcast_episode.py,sha256=4j2J2lltmMLEv7aOKF8ZHSMkBTzoVNmbcrp6lLkrvo4,768
17
- deezer_python_gql/generated/client.py,sha256=LK3cUn2JLfkAuTEaqg70UPa-vVkE-3KSYdCuV6TNSV0,147241
17
+ deezer_python_gql/generated/client.py,sha256=1vrW6aKe5SeWxt-kZjvOM0XFPbXm1bFtMe11D34vioQ,148186
18
18
  deezer_python_gql/generated/create_playlist.py,sha256=Q8pZWQ2eFIuFnl1US9trXHfFoqX_W2asJKAZqZN_Mig,534
19
19
  deezer_python_gql/generated/delete_playlist.py,sha256=1lxExq1_46RLWCdhceRHCx-0NzWPCmM7prehZahOWmo,406
20
20
  deezer_python_gql/generated/enums.py,sha256=5rdrcheqYe2L2tlkGuhNo7JYdBANWkQnaiabLVudQHU,1205
21
- deezer_python_gql/generated/fragments.py,sha256=WY8c0CjVFqcpVrv7vjmZ46zNQRw17TtzCcHJfzd4arw,7902
21
+ deezer_python_gql/generated/fragments.py,sha256=J9QVnFEVXprV5xkrOBm4Slo5Qc2YVJpH0SUPxTZ8AKE,8177
22
22
  deezer_python_gql/generated/get_album.py,sha256=EKQIFdKOmlEDhtybeWgl6lbVExbnCNA-37r2CXPVevs,1574
23
23
  deezer_python_gql/generated/get_artist.py,sha256=KKrUXF4WJDrjb9uDfHzEbGXna5fTHbfPQMwP2HJfrdo,2287
24
24
  deezer_python_gql/generated/get_artist_mix.py,sha256=aMIKKCf8dmqTisK245gIMhwVVOmXqIdc3LAUCK_GGmo,647
@@ -27,6 +27,7 @@ deezer_python_gql/generated/get_audiobook_chapter.py,sha256=AP_wamDYsZotzK86uj_K
27
27
  deezer_python_gql/generated/get_banned_artists.py,sha256=nJ3pukJJ-5jX-AZREIah1NX2u1zkhxUMnS__llufC4M,1560
28
28
  deezer_python_gql/generated/get_banned_tracks.py,sha256=VagHLhp6Ap75ajei65R6t-CWzg4p86wpZgEHMVOGj4w,1527
29
29
  deezer_python_gql/generated/get_charts.py,sha256=hu6mGPA3V5_-OU7mvHE1MbN2k0fRKCIPih5fh6HE3Gw,3004
30
+ deezer_python_gql/generated/get_family.py,sha256=4-hc2ZjVQcpmWgbhK3kHArQnj5quCmwIORT9zIhUAcc,634
30
31
  deezer_python_gql/generated/get_favorite_albums.py,sha256=oOj9BJbN1FIoGGTnIAcwcTGKiapK9-n671yem-U2Xjs,1335
31
32
  deezer_python_gql/generated/get_favorite_artists.py,sha256=-XbMVy2Y9EeQD068yRMjF_GZqQfu0Xt49nWTzONXFL0,1366
32
33
  deezer_python_gql/generated/get_favorite_audiobooks.py,sha256=NvTSyXVIDXTCy2tIxZfF1b8LJAlhC2Fl2-WyookE4H8,763
@@ -85,8 +86,8 @@ deezer_python_gql/generated/unban_artist_from_recommendation.py,sha256=mUM5zp_MI
85
86
  deezer_python_gql/generated/unban_track_from_recommendation.py,sha256=idpo4keNegu5l-7I8OorOdWa8fDE7igMzW1zJRxCg9M,715
86
87
  deezer_python_gql/generated/unbookmark_podcast_episode.py,sha256=-GjprmbpIjzyTsx9ELneKG_TAas5fsMJgFUywuGo-VM,666
87
88
  deezer_python_gql/generated/update_playlist.py,sha256=L9w-b_8CLdsW4qwN0ZgcGuutyUhGQPRf9va1XlSwZhQ,534
88
- deezer_python_gql-0.19.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
89
- deezer_python_gql-0.19.0.dist-info/METADATA,sha256=qxJ5td_KBGfX9CWa3tcGSFI3y19oEFgnNYyQLkENNrE,16179
90
- deezer_python_gql-0.19.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
91
- deezer_python_gql-0.19.0.dist-info/top_level.txt,sha256=Yf7lMr1RCsfdcASo4pLoZIzA5aTa-cqzUePMX-A0QOM,18
92
- deezer_python_gql-0.19.0.dist-info/RECORD,,
89
+ deezer_python_gql-0.20.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
90
+ deezer_python_gql-0.20.0.dist-info/METADATA,sha256=7f8JHH1Q6WrFMPPKdVA0Rf4WPrP9dINcYEomlYHqcso,16849
91
+ deezer_python_gql-0.20.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
92
+ deezer_python_gql-0.20.0.dist-info/top_level.txt,sha256=Yf7lMr1RCsfdcASo4pLoZIzA5aTa-cqzUePMX-A0QOM,18
93
+ deezer_python_gql-0.20.0.dist-info/RECORD,,