Skip to content

Commit 7e6aeae

Browse files
Streamline GraphQL fragments and constants
Combine EpisodeDetails and SeasonDetails constants, EpisodeDetails is always needed for SeasonDetails. Extract basic data from ContentDetails to BasicContentDetails, which can be used in EpisodeDetails.
1 parent 827688c commit 7e6aeae

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

src/simplejustwatchapi/query.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,13 @@
165165
}
166166
__typename
167167
}
168-
"""
169168
170-
_GRAPHQL_EPISODE_FRAGMENT = """
171169
fragment EpisodeDetails on Episode {
172170
id
173171
objectId
174172
objectType
175173
content(country: $country, language: $language) {
176-
title
177-
originalReleaseYear
178-
originalReleaseDate
179-
runtime
180-
shortDescription
174+
...BasicContentDetails
181175
episodeNumber
182176
seasonNumber
183177
__typename
@@ -190,13 +184,17 @@
190184
"""
191185

192186
_GRAPHQL_CONTENT_FRAGMENT = """
193-
fragment ContentDetails on MovieOrShowOrSeasonContent {
187+
fragment BasicContentDetails on MovieOrShowOrSeasonOrEpisodeContent {
194188
title
195-
fullPath
196189
originalReleaseYear
197190
originalReleaseDate
198191
runtime
199192
shortDescription
193+
}
194+
195+
fragment ContentDetails on MovieOrShowOrSeasonContent {
196+
...BasicContentDetails
197+
fullPath
200198
genres {
201199
shortName
202200
__typename
@@ -695,7 +693,6 @@ def prepare_details_request(node_id: str, country: str, language: str, best_only
695693
_GRAPHQL_DETAILS_QUERY
696694
+ _GRAPHQL_DETAILS_FRAGMENT
697695
+ _GRAPHQL_FULL_SHOW_FRAGMENT
698-
+ _GRAPHQL_EPISODE_FRAGMENT
699696
+ _GRAPHQL_CONTENT_FRAGMENT
700697
+ _GRAPHQL_OFFER_FRAGMENT
701698
),

0 commit comments

Comments
 (0)