/
/
/
1"""Helper to provide the GraphQL Queries."""
2
3from gql import gql
4
5image_list = """
6imagesList {
7 title
8 url
9 width
10 aspectRatio
11}
12"""
13
14
15audio_list = """
16audioList {
17 audioBitrate
18 href
19 audioCodec
20 availableFrom
21 availableTo
22}
23"""
24
25
26publication_service_metadata = """
27 title
28 genre
29 synopsis
30 homepageUrl
31 socialMediaAccounts {
32 url
33 service
34 }
35"""
36
37
38organizations_query = gql(
39 """
40query Organizations {
41 organizations {
42 nodes {
43 coreId
44 name
45 title
46 publicationServicesByOrganizationName {
47 nodes {
48 coreId
49 title"""
50 + image_list
51 + """
52 }
53 }
54 }
55 }
56}
57"""
58)
59
60
61publication_services_query = gql(
62 """
63query PublicationServices ($coreId: String!) {
64 organizationByCoreId(coreId: $coreId) {
65 publicationServicesByOrganizationName {
66 nodes {
67 coreId
68 title
69 synopsis"""
70 + image_list
71 + """
72 }
73 }
74 }
75}
76"""
77)
78
79
80publications_list_query = gql(
81 """
82query Publications($coreId: String!) {
83 publicationServiceByCoreId(coreId: $coreId) {
84 permanentLivestreams {
85 nodes {
86 title
87 coreId
88 publicationService {"""
89 + publication_service_metadata
90 + """
91 }"""
92 + image_list
93 + """
94 }
95 }
96 shows {
97 nodes {
98 coreId
99 title
100 synopsis
101 items {
102 totalCount
103 }
104 publicationService {"""
105 + publication_service_metadata
106 + """
107 }
108 editorialCategoriesList {
109 title
110 }"""
111 + image_list
112 + """
113 }
114 }
115 }
116}
117"""
118)
119
120
121livestream_query = gql(
122 """
123query Livestream($coreId: String!) {
124 permanentLivestreamByCoreId(coreId: $coreId) {
125 publisherCoreId
126 summary
127 current
128 title
129 publicationService {"""
130 + publication_service_metadata
131 + """
132 }"""
133 + image_list
134 + audio_list
135 + """
136 }
137}
138"""
139)
140
141
142show_length_query = gql("""
143query Show($showId: ID!, $filter: ItemFilter) {
144 show(id: $showId) {
145 items(filter: $filter) {
146 totalCount
147 }
148 }
149}
150""")
151
152
153show_query = gql(
154 """
155query Show($showId: ID!, $first: Int, $offset: Int, $filter: ItemFilter) {
156 show(id: $showId) {
157 synopsis
158 title
159 showType
160 items(first: $first, offset: $offset, filter: $filter) {
161 totalCount
162 nodes {
163 duration
164 title
165 status
166 episodeNumber
167 coreId
168 summary"""
169 + audio_list
170 + image_list
171 + """
172 }
173 }
174 editorialCategoriesList {
175 title
176 }
177 publicationService {"""
178 + publication_service_metadata
179 + """
180 }"""
181 + image_list
182 + """
183 }
184}
185"""
186)
187
188
189show_episode_query = gql(
190 """
191query ShowEpisode($coreId: String!) {
192 itemByCoreId(coreId: $coreId) {
193 show {
194 title
195 }
196 duration
197 title
198 episodeNumber
199 coreId
200 showId
201 rowId
202 synopsis
203 summary"""
204 + audio_list
205 + image_list
206 + """
207 }
208}
209"""
210)
211
212
213search_shows_query = gql(
214 """
215query Search($query: String, $limit: Int) {
216 search(query: $query, limit: $limit) {
217 shows {
218 totalCount
219 title
220 nodes {
221 synopsis
222 title
223 coreId"""
224 + image_list
225 + """
226 publicationService {"""
227 + publication_service_metadata
228 + """
229 }
230 items {
231 totalCount
232 }
233 showType
234 editorialCategoriesList {
235 title
236 }
237 }
238 }
239 }
240}
241"""
242)
243
244
245search_radios_query = gql(
246 """
247query RadioSearch($filter: PermanentLivestreamFilter, $first: Int) {
248 permanentLivestreams(filter: $filter, first: $first) {
249 nodes {
250 coreId
251 title"""
252 + image_list
253 + """
254 publicationService {"""
255 + publication_service_metadata
256 + """
257 }
258 }
259 }
260}
261"""
262)
263
264
265check_login_query = gql(
266 """
267query CheckLogin($loginId: String!) {
268 allEndUsers(filter: { loginId: { eq: $loginId } }) {
269 count
270 nodes {
271 id
272 syncSuccessful
273 }
274 }
275}
276"""
277)
278
279
280get_subscriptions_query = gql(
281 """
282query GetBookmarksByLoginId($loginId: String!) {
283 allEndUsers(filter: { loginId: { eq: $loginId } }) {
284 count
285 nodes {
286 subscriptions {
287 programSets {
288 nodes {
289 subscribedProgramSet {
290 coreId
291 }
292 }
293 }
294 }
295 }
296 }
297}
298"""
299)
300
301
302get_history_query = gql(
303 """
304query GetBookmarksByLoginId($loginId: String!, $count: Int = 96) {
305 allEndUsers(filter: { loginId: { eq: $loginId } }) {
306 count
307 nodes {
308 history(first: $count, orderBy: LASTLISTENEDAT_DESC) {
309 nodes {
310 progress
311 item {
312 coreId
313 duration
314 }
315 }
316 }
317 }
318 }
319}
320"""
321)
322
323update_history_entry = gql(
324 """
325mutation AddHistoryEntry(
326 $itemId: ID!
327 $progress: Float!
328) {
329 upsertHistoryEntry(
330 input: {
331 item: { id: $itemId }
332 progress: $progress
333 }
334 ) {
335 changedHistoryEntry {
336 id
337 progress
338 lastListenedAt
339 }
340 }
341}"""
342)
343