|
@@ -171,19 +171,23 @@ class Source(SourceBase):
|
171
|
171
|
m = re.search('datePublished" datetime="([^"]+)"', item, re.DOTALL)
|
172
|
172
|
if m:
|
173
|
173
|
published = m.group(1)
|
174
|
|
- published = datetime.datetime.strptime(published,"%Y-%m-%dT%H:%M:%SZ")
|
175
|
|
- published = util.datetime_from_utc_to_local(published)
|
176
|
|
- published_datetime = datetime.datetime.strftime(published,"%d.%m.%Y %H:%M")
|
177
|
|
- published_date = datetime.datetime.strftime(published,"%d.%m.%Y")
|
178
|
|
- title = title + " (%s)" % published_date
|
179
|
|
- desc = desc + "\nPublished: %s" % published_datetime
|
|
174
|
+ try:
|
|
175
|
+ published = util.datetime_from_zulu_to_utc(published)
|
|
176
|
+ published = util.datetime_from_utc_to_local(published)
|
|
177
|
+ published_datetime = datetime.datetime.strftime(published,"%d.%m.%Y %H:%M")
|
|
178
|
+ published_date = datetime.datetime.strftime(published,"%d.%m.%Y")
|
|
179
|
+ title = title + " (%s)" % published_date
|
|
180
|
+ desc = desc + "\nPublished: %s" % published_datetime
|
|
181
|
+ except:
|
|
182
|
+ a = 1
|
|
183
|
+ pass
|
180
|
184
|
m = re.search('thumbnail__duration">([^<]+)<', item, re.DOTALL)
|
181
|
185
|
if m:
|
182
|
186
|
desc = desc + "\nDuration: %s" % m.group(1)
|
183
|
187
|
m = re.search(r'<a href="https://replay\.lsm\.lv/lv/raidijums/[^"]+">([^<]+)</a>', item, re.DOTALL)
|
184
|
188
|
if m:
|
185
|
189
|
desc = desc + "\nProgram: %s" % m.group(1)
|
186
|
|
- m = re.search('<li class="">(Vēl[^<]+)</li>', item, re.DOTALL)
|
|
190
|
+ m = re.search('<li class=".*?">(Vēl[^<]+)</li>', item, re.DOTALL)
|
187
|
191
|
if m:
|
188
|
192
|
desc = desc + "\nRemaining: %s" % m.group(1)
|
189
|
193
|
content.append((title,self.name+"::"+data2,img,desc))
|
|
@@ -202,28 +206,29 @@ class Source(SourceBase):
|
202
|
206
|
|
203
|
207
|
return content
|
204
|
208
|
|
205
|
|
-
|
206
|
|
-
|
|
209
|
+ #===========================================================================
|
207
|
210
|
def get_streams(self, data):
|
208
|
211
|
source, data, path, plist, clist, params, qs = self.parse_data(data)
|
209
|
|
- lang = qs["lang"] if "lang" in qs else self.country
|
|
212
|
+ lang = "ru" if clist == 'statja' else "lv"
|
|
213
|
+ headers2 = {}
|
|
214
|
+ nfo = {}
|
210
|
215
|
|
211
|
216
|
### Kanāla tiesraide
|
212
|
|
- # TODO - jāuztaisa get_streams/get_info
|
213
|
217
|
if clist == "tiesraide" and "/" in data:
|
214
|
218
|
r = self.call(data, lang=lang)
|
215
|
219
|
ch = data.split('/')[1]
|
|
220
|
+
|
216
|
221
|
veids = "audio" if "lr" in ch else "video"
|
217
|
|
- #url = "https://replay.lsm.lv/lv/tiesraide/ltv7/"
|
218
|
222
|
url = "https://replay.lsm.lv/lv/tiesraide/%s/"%ch
|
219
|
|
- r= self._http_request(url)
|
|
223
|
+ r = self._http_request(url)
|
220
|
224
|
|
221
|
225
|
m = re.search('span class="badge badge-primary">Tagad</span>([^<]+)<.+?<time>([^<]+)</time>', r, re.DOTALL)
|
222
|
226
|
tagad = m.group(1).strip() if m else ""
|
223
|
227
|
laiks = m.group(2).strip() if m else ""
|
224
|
228
|
laiks = h.unescape(laiks).encode("utf8")
|
225
|
229
|
title = m.group(1).strip() if m else path.split("/")[1].upper()
|
226
|
|
- title = "%s - %s [%s]"%(ch.upper(), title,laiks)
|
|
230
|
+ dd = datetime.datetime.now().strftime("%d.%m.%Y")
|
|
231
|
+ title = "%s - %s (%s) [%s]"%(ch.upper(), title, dd, laiks)
|
227
|
232
|
desc = title
|
228
|
233
|
|
229
|
234
|
if veids == "video":
|
|
@@ -241,16 +246,21 @@ class Source(SourceBase):
|
241
|
246
|
m = re.search(r'iframe src=\\"([^"]+)\\', r)
|
242
|
247
|
if not m:
|
243
|
248
|
raise Exception("No stream found")
|
244
|
|
- url = m.group(1).replace('\\/', "/")
|
|
249
|
+ url2 = m.group(1).replace('\\/', "/")
|
245
|
250
|
m = re.search('poster":"([^"]+)"', r, re.DOTALL)
|
246
|
251
|
img = "https://ltv.lsm.lv" + m.group(1).replace("\\","") if m else ch + '.png'
|
247
|
252
|
|
248
|
|
- r = self._http_request(url,headers=headers)
|
|
253
|
+ r = self._http_request(url2,headers=headers)
|
249
|
254
|
m = re.search('"([^"]+m3u8[^"]+)"', r)
|
250
|
255
|
if not m:
|
251
|
256
|
raise Exception("No stream found")
|
252
|
257
|
data2 = m.group(1).replace("\\","")
|
253
|
|
- #r = self._http_request(data2, headers=headers)
|
|
258
|
+ headers2["Referer"] = url2
|
|
259
|
+ headers2["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"
|
|
260
|
+ headers2["Origin"] = "https://embed.lsm.lv"
|
|
261
|
+ headers2["Host"] = data2.split("/")[2]
|
|
262
|
+ #r = self._http_request(data2, headers=headers2)
|
|
263
|
+ a = 1
|
254
|
264
|
|
255
|
265
|
else: # audio
|
256
|
266
|
lrn = ch.replace("lr","")
|
|
@@ -270,35 +280,74 @@ class Source(SourceBase):
|
270
|
280
|
if not m:
|
271
|
281
|
raise Exception("No stream found")
|
272
|
282
|
url2 = m.group(1).replace("&", "&")
|
273
|
|
- m = re.search('<h1 class="title">([^<]+)</h1>', r)
|
274
|
|
- title = m.group(1).strip()
|
|
283
|
+ #m = re.search('<h1 class="title">([^<]+)</h1>', r)
|
|
284
|
+ m = re.search('<meta name="name" content="([^"]+)">', r)
|
|
285
|
+ title = m.group(1)
|
|
286
|
+ title = title.replace("- REplay.lv", "")
|
|
287
|
+ title = title.strip()
|
|
288
|
+ m = re.search('<meta content="([^"]+)" property="og:video:release_date"', r)
|
|
289
|
+ if m:
|
|
290
|
+ dd = m.group(1).split("T")[0].split("-")
|
|
291
|
+ title += " (%s.%s.%s)" % (dd[2], dd[1], dd[0])
|
275
|
292
|
m = re.search('<meta content="([^"]+)" property="og:image">', r)
|
276
|
293
|
img = m.group(1) if m else ""
|
277
|
294
|
m = re.search('<div class="description">(.+?)</div>', r, re.DOTALL)
|
278
|
295
|
if m:
|
279
|
|
- desc = m.group(1)
|
|
296
|
+ plot = m.group(1)
|
280
|
297
|
rr = re.sub("<.+?>", " ", m.group(1))
|
281
|
298
|
rr = re.sub("[\t\n]", " ", rr)
|
282
|
|
- desc = re.sub(" {2,100}", " ", rr).strip()
|
|
299
|
+ plot = re.sub(" {2,100}", " ", rr).strip()
|
283
|
300
|
else:
|
284
|
|
- desc = ""
|
|
301
|
+ plot = ""
|
|
302
|
+ desc = [title]
|
|
303
|
+ m = re.search(r'<figure><span class="channel-logo (\w+)"></span></figure>([^<]+)</a>', r, re.IGNORECASE)
|
|
304
|
+ if m:
|
|
305
|
+ desc.append("Programma: %s [%s]" % (m.group(2), m.group(1).upper()))
|
|
306
|
+ m = re.search('<ul class="media-info-list">(.+?)</ul>', r, re.DOTALL)
|
|
307
|
+ if m:
|
|
308
|
+ for m2 in re.finditer("<strong>([^<]+)</strong> *(<a[^<]+?>)*([^<]+)*<", m.group(1)):
|
|
309
|
+ desc.append("%s %s" % (m2.group(1).strip(),m2.group(3).strip() if m2.group(3) else ""))
|
|
310
|
+ m2 = re.search('li class="[^"]*">(Pieejam.+)</li>', m.group(1))
|
|
311
|
+ if m2:
|
|
312
|
+ desc.append(m2.group(1))
|
|
313
|
+ desc.append(plot)
|
|
314
|
+ desc = "\n".join(desc)
|
|
315
|
+
|
285
|
316
|
headers = headers2dict("""
|
286
|
317
|
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36
|
287
|
318
|
Referer: https://replay.lsm.lv/%s/%s
|
288
|
|
-Host: ltv.lsm.lv
|
289
|
319
|
"""% (lang, data))
|
290
|
320
|
r2 = self._http_request(url2,headers=headers)
|
291
|
321
|
m = re.search(r"<script>LTV.Video.players.create\('videoplay', ({.+?})\);</script>", r2, re.DOTALL)
|
292
|
322
|
#m = re.search('"file":"([^"]+)', r2)
|
293
|
|
- if not m:
|
294
|
|
- raise Exception("No stream found")
|
295
|
|
- js = json.loads(m.group(1))
|
296
|
|
- if "playlist" in js["player"]:
|
297
|
|
- data2 = js["player"]["playlist"][0]["sources"][0]["file"]
|
298
|
|
- elif "file" in js["player"]:
|
299
|
|
- data2 = js["player"]["file"]
|
300
|
|
- else:
|
301
|
|
- raise Exception("No stram found")
|
|
323
|
+ if m:
|
|
324
|
+ js = json.loads(m.group(1))
|
|
325
|
+ if js["ext_video_id"]:
|
|
326
|
+ data2 = "https://www.youtube.com/watch?v=" + js["ext_video_id"]
|
|
327
|
+ elif "playlist" in js["player"]:
|
|
328
|
+ data2 = js["player"]["playlist"][0]["sources"][0]["file"]
|
|
329
|
+ elif "clip" in js["player"]:
|
|
330
|
+ if len(js["player"]["clip"]["sources"]) > 0:
|
|
331
|
+ data2 = js["player"]["clip"]["sources"][0]["src"]
|
|
332
|
+ else:
|
|
333
|
+ raise Exception("No streams found!")
|
|
334
|
+ elif "file" in js["player"]:
|
|
335
|
+ data2 = js["player"]["file"]
|
|
336
|
+ else:
|
|
337
|
+ raise Exception("No stram found")
|
|
338
|
+ else: # futbols u.c.
|
|
339
|
+ m = re.search('<div class="video-player">.+?<iframe src="([^"]+)', r2, re.DOTALL)
|
|
340
|
+ if not m:
|
|
341
|
+ raise Exception("No stream found")
|
|
342
|
+ url3 = "https:" + m.group(1)
|
|
343
|
+ headers["Referer"] = url2
|
|
344
|
+ r3 = self._http_request(url3, headers=headers)
|
|
345
|
+ m = re.search(r"src: '([^']+)',\s+?type: 'application/x-mpegurl'", r3, re.DOTALL)
|
|
346
|
+ if not m:
|
|
347
|
+ raise Exception("No stream found")
|
|
348
|
+ data2 = "https:" + m.group(1)
|
|
349
|
+
|
|
350
|
+
|
302
|
351
|
if "youtube" in data2:
|
303
|
352
|
video_id = re.search(r"/watch\?v=([^&]+)",data2).group(1)
|
304
|
353
|
data2 = YouTubeVideoUrl().extract(video_id)
|
|
@@ -311,6 +360,9 @@ Host: ltv.lsm.lv
|
311
|
360
|
stream["img"] = img
|
312
|
361
|
stream["desc"] = desc
|
313
|
362
|
stream["resolver"] = "replay"
|
|
363
|
+ stream["headers"] = headers2
|
|
364
|
+ stream["nfo"] = nfo
|
|
365
|
+ #stream["filename"] = filename # TODO jāģenere jēdzigs faila nosaukums, kuru pēc tam izmanto downloadsb
|
314
|
366
|
return [stream]
|
315
|
367
|
|
316
|
368
|
def is_video(self,data):
|