Browse Source

salabots shortcut videonoma

Ivars 6 years ago
parent
commit
a74e4df852
3 changed files with 766 additions and 346 deletions
  1. 5
    1
      changelog.md
  2. 608
    325
      project.wpr
  3. 153
    20
      sources/ltc.py

+ 5
- 1
changelog.md View File

@@ -1,3 +1,7 @@
1
+**10.04.2018**:
2
+- salaboti shortcut.lv videonomas saraksti
3
+
1 4
 **10.03.2018**:
2
-- filmix turlkojumi/srīmi salaboti (nerādīja visas sērijas u.c.)
5
+- filmix tulkojumi/strīmi salaboti (nerādīja visas sērijas u.c.)
6
+
3 7
 

+ 608
- 325
project.wpr
File diff suppressed because it is too large
View File


+ 153
- 20
sources/ltc.py View File

@@ -47,6 +47,11 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0
47 47
 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
48 48
 Accept-Language: en-US,en;q=0.8
49 49
         """)
50
+        self.headers3 = headers2dict("""
51
+User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
52
+Content-Type: application/x-www-form-urlencoded; charset=UTF-8
53
+X-Requested-With: XMLHttpRequest
54
+        """)
50 55
 
51 56
         self.channels = None
52 57
         ### specific service info ###
@@ -80,12 +85,18 @@ Accept-Language: en-US,en;q=0.8
80 85
 
81 86
         if clist=="home":
82 87
             content.extend([
83
-                #("Meklēt TV arhīvā", "ltc::search/{0}","","Meklēt TV arhīvā"), #TODO
84
-                ("Meklēt filmas", "ltc::viss/search/?cat=movies&q={0}","","Meklēt filmu sadaļa"),
85
-                ("Meklēt seriālus", "ltc::viss/search/?cat=series&q={0}","", "Meklēt seriālu sadaļā"),
86 88
                 ("TV tiešraides", "ltc::tiesraide","","TV tiešraides"),
87 89
                 ("TV arhīvs", "ltc::arhivs","","TV arhīvs atseviškiem kanāliem"),
88
-                ("Videonoma", "ltc::videonoma","","Filmas (arī Priemiere) un seriāli"),
90
+                ("Bērnu", "ltc::videonoma/bernu","","Videonomas bērnu filmas un seriāli"),
91
+                ("Filmas", "ltc::videonoma/filmas","","Videonomas filmas"),
92
+                ("Premiere filas", "ltc::videonoma/premiere","","Videonomas premiere filmas"),
93
+                ("Seriāli", "ltc::videonoma/series","","Videonomas seriāli"),
94
+                ("360 Play", "ltc::videonoma/360play","","Videonomas lattelecom saturs"),  # TODO
95
+                #("Videonoma", "ltc::videonoma","","Filmas (arī Priemiere) un seriāli"),
96
+                ("Meklēt filmas", "ltc::viss/search/?cat=movies&q={0}","","Meklēt filmu sadaļa"),
97
+                ("Meklēt seriālus", "ltc::viss/search/?cat=series&q={0}","", "Meklēt seriālu sadaļā"),
98
+                #("Meklēt TV arhīvā", "ltc::viss/search/?cat=archive&q={0}","", "Meklēt TV arhīvā"),
99
+                #("Meklēt TV arhīvā", "ltc::search/{0}","","Meklēt TV arhīvā"), #TODO
89 100
             ])
90 101
             return content
91 102
 
@@ -98,15 +109,21 @@ Accept-Language: en-US,en;q=0.8
98 109
         elif path == 'viss/search/': #TODO vod/search/{q}
99 110
             r = self.call2(data)
100 111
             if "cat=movies" in data:
101
-                result = re.findall('class="forward-link" href="/([^"]+)">(<div class="new-movie">Premiere</div>)*<img src="([^"]+)".+?class="categorie-one-title">([^<]+)<', r, re.MULTILINE)
112
+                result = re.findall(r'class="forward-link" href="/([^"]+)/">(<div class="new-movie">(\w+)</div>)*<img src="([^"]+)".+?class="categorie-one-title">([^<]+)</div><div class="categorie-one-subtitle">([^<]+)<', r, re.DOTALL)
113
+            elif "cat=series" in data:
114
+                result = re.findall(r'class="forward-link" href="/([^"]+)/">(<div class="new-movie">(\w+)</div>)*<img src="([^"]+)".+?class="categorie-one-title">([^<]+)</div><div class="categorie-one-subtitle">([^<]+)<', r, re.DOTALL)
102 115
             else:
103
-                result = re.findall('class="forward-link" href="/([^"]+)">(<div class="new-movie">Premiere</div>)*<img src="([^"]+)".+?class="categorie-one-title">([^<]+)<', r, re.MULTILINE)
116
+                result = re.findall(r'class="forward-link" href="/([^"]+)/">(<div class="new-movie">(\w+)</div>)*<img src="([^"]+)".+?class="categorie-one-title">([^<]+)</div><div class="categorie-one-subtitle">([^<]+)<', r, re.DOTALL)
104 117
             for item in result:
105
-                title = item[3]
106
-                if not item[1]:
107
-                    title = title + "[P]"
108
-                data2 = item[0][0:-1]
109
-                img = "https://www.shortcut.lv" + item[2]
118
+                title1 = item[4]
119
+                title2 = item[5]
120
+                title = "%s ~ %s" % (title1, title2)
121
+                if item[1]:
122
+                    title = title + "[J]" if item[2] == "Jaunums" else title + "[P]"
123
+                data2 = item[0]
124
+                if re.search("e\d+$", data2):
125
+                    data2 += "?series"
126
+                img = "https://www.shortcut.lv" + item[3]
110 127
                 desc = title
111 128
                 content.append((title,self.name+"::"+data2,img,desc))
112 129
             return content
@@ -275,7 +292,7 @@ Accept-Language: en-US,en;q=0.8
275 292
             return content
276 293
 
277 294
 
278
-        ### Videonoma galvenā
295
+        ### Videonoma galvenā (vecā, vairs nestrada filtri)
279 296
         elif data=="videonoma":
280 297
             content.extend([
281 298
                 ("Filmas - jaunākās", "ltc::videonoma?page=0&genre=all_movies&sorts=laiks&cnt=40&clear=true&filter={}","https://www.shortcut.lv/media/features/2013-12-17/aa3b_videonoma_dropdown_filmas.png","Jaunākās filmas"),
@@ -299,7 +316,7 @@ Accept-Language: en-US,en;q=0.8
299 316
             ])
300 317
             return content
301 318
 
302
-        ### Videonomas saraksti
319
+        ### Videonomas saraksti (vecie, vairs nestrādā filtri)
303 320
         elif path == "videonoma":
304 321
             url = "https://www.shortcut.lv/movies-snippet.json"+params
305 322
             r = self._http_request(url,headers=self.headers2)
@@ -329,6 +346,116 @@ Accept-Language: en-US,en;q=0.8
329 346
                 content.append(("Next page",self.name+"::"+data2,"","Go to next page"))
330 347
             return content
331 348
 
349
+        ### Filmas galvenā ###
350
+        elif data == "videonoma/filmas":
351
+            content.extend([
352
+                ("Aktuālās", "ltc::viss/actual_films","","Nesen pievienotas filmas"),
353
+                ("Komēdijas", "ltc::viss/comedy","","Komēdijas"),
354
+                ("Detektīvi", "ltc::viss/crime","","Detektivi"),
355
+                ("Ģimenes", "ltc::viss/family","","Ģimenes filmas"),
356
+                ("Asa sižeta", "ltc::viss/action","","Asa sižeta filmas"),
357
+                ("Romantika", "ltc::viss/romance","","Romantiskās filmas"),
358
+                ("Piedzīvojumu", "ltc::viss/adventure","","Piedzivojumu filmas"),
359
+                ("Supervaroņi", "ltc::viss/superheros","","Supervaroņu filmas"),
360
+                ("Fantastika", "ltc::viss/scifi","","Fantastikas filmas"),
361
+                ("Dokumentalās", "ltc::viss/documentaries","","Dokumentalās filmas"),
362
+                ("Šausmu", "ltc::viss/horror","","Šausmu filmas"),
363
+                ("Retro", "ltc::viss/retro_films","","Retro filmas"),
364
+                ("Koncerti un karaoke", "ltc::viss/concerts_karaoke","","Koncerti un filmas"),
365
+            ])
366
+
367
+        ### Sērijas galvenā ###
368
+        elif data == "videonoma/series":
369
+            content.extend([
370
+                ("Aktuālie seriāli", "ltc::viss/actual_series?series","","Nesen pievienotie seriāli"),
371
+                ("Aktuālie šovi", "ltc::viss/actual_series?series","","Nesen pievienotie TV šovi"),
372
+                ("Populārākie seriāli", "ltc::viss/popular_series?series","","Populārākie seriāli"),
373
+                ("Dokumentalie seriāli", "ltc::viss/documentary?series","","Dokumentalie seriāli"),
374
+                ("Izklaides pārraides", "ltc::viss/entertainment?series","","Izklaides pārraides"),
375
+                ("Detektivseriāli", "ltc::viss/Crime_series?series","","Detektivseriāli"),
376
+                ("Dramas seriāli", "ltc::viss/drama_series?series","","Dramas seriāli"),
377
+                ("Par dabu", "ltc::viss/nature?series","","Seriāli par dabu"),
378
+                ("Gardēžiem", "ltc::viss/gourmets?series","","Seriāli gardēžiem"),
379
+                ("Mistērija", "ltc::viss/mystery_series?series","","Mistērijas seriāli"),
380
+                ("Oriģinālsaturs", "ltc::viss/originals_series?series","","Oriģinālsatura seriāli"),
381
+                ("Klasika", "ltc::viss/classic?series","","Klasika"),
382
+            ])
383
+
384
+        ### Bērnu galvenā ###
385
+        elif data == "videonoma/bernu":
386
+            content.extend([
387
+                ("Nesen pievienotais", "ltc::viss/actual_kid","","Nesen pievienotais bernu saturs"),
388
+                ("Bērnu Premiere", "ltc::viss/kids_premiere","","Bērnu Premiere saturs"),
389
+                ("Multfilmas", "ltc::viss/animation2","","Multfilmas"),
390
+                ("Bērnu seriāli", "ltc::viss/kids_series?series","","Bērnu seriāli"),
391
+                ("Ģimenes filmas", "ltc::viss/family","","Ģimenes filmas"),
392
+                ("Multfilmas latviski", "ltc::viss/animation_lv","","Multfilmas latviski"),
393
+                ("Retro multfilmas", "ltc::viss/retro_animation","","Retro multfilmas"),
394
+                ("Latviešu multfilmas", "ltc::viss/animation","","Latviešu multfilmas"),
395
+                ("Raidijumi berniem", "ltc::viss/kids_events","","Raidijumi berniem"),
396
+            ])
397
+
398
+        ### Filmas premiere galvenā ###
399
+        elif data == "videonoma/premiere":
400
+            content.extend([
401
+                ("Aktuālās Premiere filmas", "ltc::viss/actual_premiere","","Nesen pievienotās Premiere filmas"),
402
+                ("Tikko no kinoteātra", "ltc::viss/just_from_cinema","","Filmas tikko no kinoteātra"),
403
+                ("Bērnu Premiere", "ltc::viss/kids_premiere","","Bērnu Premiere saturs"),
404
+                ("Komēdijas Premiere", "ltc::viss/comedy_premiere","","Premiere komēdijas filmas"),
405
+                ("Detektivi Premiere", "ltc::viss/crime_premiere","","Premiere detektivfilmas"),
406
+                ("Piedzīvojumu Premiere", "ltc::viss/adventure_premiere","","Premiere piedzivojumu filmas"),
407
+                ("Fantastika Premiere", "ltc::viss/scifi_premiere","","Premiere fantastikas filmas"),
408
+                ("Šausmu Premiere", "ltc::viss/horror_premiere","","Premiere šausmu filmas"),
409
+            ])
410
+
411
+        ### 360 Play galvenā ###
412
+        elif data == "videonoma/360play":
413
+            content.extend([
414
+                ("Viss", "ltc::viss/bezmaksas?series","","Viss bezmaksas saturs"),
415
+                ("360TV", "ltc::viss/360_free?series","","360TV bezmaksas saturs"),
416
+                ("Red Bull", "ltc::viss/Red_bull?series","","Red Bull bezmaksas saturs"),
417
+            ])
418
+            r = self.call
419
+
420
+        ### Videonomas saraksti ###
421
+        elif plist[0] == "viss" or "load_more" in data:
422
+            #content.append(("Videonomas saraksts", "", "", ""))
423
+            if "viss" in data:
424
+                r = self.call2(data)
425
+                m = re.search('(<div class="container categorie">.+?)</div><div class="loader off">', r, re.DOTALL)
426
+                html = m.group(1) if m else ""
427
+            else:
428
+                url = self.api_url2 + path
429
+                params = data.split("?")[1]
430
+                r = self._http_request(url, params, headers=self.headers3 )
431
+                js = json.loads(r)
432
+                html = js["data"] if "data" in r else ""
433
+            result = re.findall("<div title=.+?</a>", html, re.DOTALL)
434
+            for it in result:
435
+                title1 = re.search('<div class="categorie-one-title">(.+?)<', it, re.DOTALL).group(1)
436
+                title2 = re.search('<div class="categorie-one-subtitle">(.+?)<', it, re.DOTALL).group(1)
437
+                title = "%s ~ %s" % (title1, title2)
438
+                img = self.api_url2 + re.search('img src="(.+?)"', it).group(1)
439
+                data2 = re.search('href="/(.+?)/"', it).group(1)
440
+                if "?series" in data or re.search("e\d+$", data2):
441
+                    data2 += "?series"
442
+                if "Jaunums" in it:
443
+                    title += " [J]"
444
+                if "Premiere" in it:
445
+                    title += " [P]"
446
+                desc = title
447
+                content.append((title,self.name+"::"+data2,img,desc))
448
+            if not "end-reached-box" in r:
449
+                if "load_more" in data:
450
+                    page = int(qs["pack"])
451
+                    data2 = re.sub("pack=\d+","pack=%s"%(page+1),data)
452
+                else:
453
+                    section = re.search('data-section="(\d+)"', r).group(1)
454
+                    data2 = "load_more.json?pack=1&section=%s" % section
455
+                content.append(("Next page",self.name+"::"+data2,"","Go to next page"))
456
+            return content
457
+
458
+
332 459
         ### Sērijas
333 460
         elif clist=="videonoma" and  (params=="?series" or "season_nr" in qs):
334 461
             url = "https://www.shortcut.lv/"+path
@@ -354,7 +481,7 @@ Accept-Language: en-US,en;q=0.8
354 481
                         img = img0
355 482
                         desc = title
356 483
                         content.append((title, self.name + "::" + data2, img, desc))
357
-                    return content
484
+                    #return content
358 485
 
359 486
                 else:  # Sezonas epizožu saraksts
360 487
                     if not "season_nr" in qs:
@@ -375,7 +502,7 @@ Accept-Language: en-US,en;q=0.8
375 502
                         img = "https://www.shortcut.lv"+item[1]
376 503
                         desc = title
377 504
                         content.append((title,self.name+"::"+data2,img,desc))
378
-                    return content
505
+                    #return content
379 506
 
380 507
             # Nav sezonu
381 508
             else:
@@ -386,10 +513,17 @@ Accept-Language: en-US,en;q=0.8
386 513
                     img = "https://www.shortcut.lv"+item[1]
387 514
                     desc = title
388 515
                     content.append((title,self.name+"::"+data2,img,desc))
389
-                return content
516
+                #return content
517
+                if not result:  # nav ne epizožu, atgriež pats sevi bez ?series
518
+                    title = desc = raidijums
519
+                    img = img0
520
+                    data2 = path
521
+                    content.append((title,self.name+"::"+data2,img,desc))
522
+            return content
523
+
390 524
 
391 525
         ### Videonomas video
392
-        elif clist=="videonoma" and len(data.split("/"))>1:
526
+        elif clist=="videonoma" and len(data.split("/"))> 2:
393 527
             ch = data.split("/")[1]
394 528
             video_id=data[data.find("/")+1:]
395 529
             #video_id=data.split("/")[-1]
@@ -411,8 +545,7 @@ Accept-Language: en-US,en;q=0.8
411 545
             content = (title,data2,"",desc)
412 546
             return content
413 547
 
414
-        else:
415
-            return content
548
+        return content
416 549
 
417 550
     def get_streams(self, data):
418 551
         print "[ltc] get_streams:", data
@@ -496,7 +629,7 @@ Accept-Language: en-US,en;q=0.8
496 629
             return True
497 630
         elif cmd[0]=="arhivs" and len(cmd)==4:
498 631
             return True
499
-        elif cmd[0]=="videonoma" and len(cmd)==3 and  not "?" in data:
632
+        elif cmd[0]=="videonoma" and len(cmd) >= 3 and  not "?" in data:
500 633
             return True
501 634
         else:
502 635
             return False