Ivars 6 years ago
parent
commit
79ef8a38a1
2 changed files with 52 additions and 31 deletions
  1. 39
    25
      sources/ltc.py
  2. 13
    6
      util.py

+ 39
- 25
sources/ltc.py View File

@@ -462,8 +462,24 @@ X-Requested-With: XMLHttpRequest
462 462
             r = self._http_request(url,headers=self.headers2)
463 463
             if not r:
464 464
                 return content
465
-            m = re.search('<div class="movie_titles"><div class="en">([^<]+)</div>', r)
466
-            raidijums = m.group(1) if m else "Series"
465
+            m = re.search(r'data-movieid=\d+><div class="lv">([^<]+)</div><div[^>]+>([^<]+)<', r)
466
+            if m:
467
+                title1 = unescape(m.group(1))
468
+                title2 = unescape(m.group(2))
469
+            else:
470
+                m = re.search('<meta name="dr:say:title" content="([^"]+)">', r, re.IGNORECASE)
471
+                title1 = title2 = unescape(m.group(1)) if m else "Video"
472
+            if 'episode_switcher_title' in r:
473
+                set1 = title1.replace("\xe2\x80\x93", "-")
474
+                if " - " in set1:
475
+                    set1 = set1.split(" - ")[0]
476
+                set2 = title2.replace("\xe2\x80\x93", "-")
477
+                if " - " in set2:
478
+                    set2 = set2.split(" - ")[0]
479
+                raidijums = "%s ~ %s" % (set1, set2)
480
+            else:
481
+                m = re.search('<div class="movie_titles"><div class="en">([^<]+)</div>', r)
482
+                raidijums = m.group(1) if m else "Series"
467 483
             img0 = re.search('<meta name="og:image" content="([^"]+)">', r).group(1) if re.search('<meta name="dr:say:img" content="([^"]+)">', r) else ""
468 484
             m = re.search('season_choice', r)
469 485
 
@@ -497,7 +513,7 @@ X-Requested-With: XMLHttpRequest
497 513
                         raise Exception("Error getting episode list")
498 514
                     result = re.findall(r'class="" href="([^"]+)".+?image:url\(([^ \)]+)\); "></div><div class="episode_titlez_design17">([^<]+)</div><div class="episode_number_design17">([^<]+)</div></a>', js["data"])
499 515
                     for item in result:
500
-                        title = "%s - %s(%s)"%(raidijums,item[2],item[3])
516
+                        title = "%s - %s (%s)"%(raidijums,item[2],item[3])
501 517
                         data2 = item[0][1:]
502 518
                         img = "https://www.shortcut.lv"+item[1]
503 519
                         desc = title
@@ -911,33 +927,31 @@ Host: manstv.lattelecom.tv
911 927
         tt = lambda p,r,d: re.search(p,r).group(1) if re.search(p,r) else d
912 928
         tt2 = lambda p,r,d: (re.sub("[\.]","",re.search(p,r).group(1))).split(", ") if re.search(p,r) else d
913 929
         r = self.call2(data)
914
-        m = re.search(r'"movie_titles" data-movieid=(\d+)><div class="en">([^<]+)</div><div class="lv translated">([^<]+)</div>', r)
930
+        m = re.search(r'data-movieid=\d+><div class="lv">([^<]+)</div><div[^>]+>([^<]+)<', r)
915 931
         if m:
916
-            title1 = unescape(m.group(2))
917
-            title2 = unescape(m.group(3))
932
+            title1 = unescape(m.group(1))
933
+            title2 = unescape(m.group(2))
918 934
         else:
919 935
             m = re.search('<meta name="dr:say:title" content="([^"]+)">', r, re.IGNORECASE)
920 936
             title1 = title2 = unescape(m.group(1)) if m else "Video"
921
-        nfo["title"] = title2
922
-        nfo["originaltitle"] = title1
937
+        nfo["title"] = title1
938
+        nfo["originaltitle"] = title2
923 939
         if nfo["originaltitle"] and not nfo["title"]:
924 940
             nfo["title"] = nfo["originaltitle"]
925 941
         if 'episode_switcher_title' in r:
926
-            title2 = title2.replace("\xe2\x80\x93", "-")
927
-            if " - " in title2:
928
-                nfo["set"] = title2.split(" - ")[0]
929
-            else:
930
-                nfo["set"] = tt('<div class="movie_titles"><div class="en">(.+?)<', r, title2)
931
-            m = re.search('<div class="serial_switcher_banner active".+?<div class="episode_titlez_design17">([^<]+)</div><div class="episode_number_design17">([^<]+)</div>', r)
932
-            if m:
933
-                ep1 = m.group(1)
934
-                ep2 = m.group(2)
935
-                nfo["title"] = "%s - %s(%s)"%(nfo["set"], ep1, ep2)
936
-                nfo["originaltitle"] = nfo["originaltitle"] + "(%s)" % ep2
937
-            m = re.search("S(\d+)E(\d+)", ep2)
942
+            set1 = title1.replace("\xe2\x80\x93", "-")
943
+            if " - " in set1:
944
+                set1 = set1.split(" - ")[0]
945
+            set2 = title2.replace("\xe2\x80\x93", "-")
946
+            if " - " in set2:
947
+                set2 = set2.split(" - ")[0]
948
+            nfo["set"] = "%s ~ %s" % (set1, set2)
949
+            m = re.search(r"<br>(S(\d+)E(\d+))<", r, re.IGNORECASE | re.DOTALL)
938 950
             if m:
939
-                nfo["season"] = m.group(1)
940
-                nfo["eposode"] = m.group(2)
951
+                #nfo["title"] = nfo["title"] + " (%s)" % m.group(1)
952
+                #nfo["originaltitle"] = nfo["originaltitle"] + " (%s)" % m.group(1)
953
+                nfo["season"] = m.group(2)
954
+                nfo["episode"] = m.group(2)
941 955
 
942 956
         nfo["thumb"] = tt('<meta name="og:image" content="([^"]+)"', r,"")
943 957
         nfo["thumb"] = nfo["thumb"].replace("http:", "https:")
@@ -945,11 +959,11 @@ Host: manstv.lattelecom.tv
945 959
         nfo["runtime"] = tt('movie-informatio-title">Garums<.+?content">([^<]+)<', r, "")
946 960
         nfo["quality"] = tt('movie-informatio-title">Kvalitāte<.+?content">([^<]+)<', r, "")
947 961
         nfo["genre"]=tt('movie-informatio-title">Žanrs<.+?content">([^<]+)<', r, "")
948
-        nfo["director"] = tt('movie-informatio-title">Režisors<.+?content">([^<]+)<', r, "")
949
-        nfo["actor"] = tt2('movie-informatio-title">Aktieri<.+?content">([^<]+)<', r, "")
962
+        nfo["director"] = tt('movie-informatio-title">Režisor.<.+?content">([^<]+)<', r, "")
963
+        nfo["actor"] = tt2('class="movie-informatio-content actors">([^<]+)<', r, "")
950 964
         nfo["language"] = tt2('movie-informatio-title">Valodas*<.+?content">([^<]+)<', r, "")
951 965
         nfo["subtitles"] = tt2('movie-informatio-title">Subtitri<.+?content">([^<]+)<', r, "")
952
-        nfo["plot"] = tt('movie-informatio-title">Apraksts<.+?content">([^<]+)<', r, "")
966
+        nfo["plot"] = tt('class="movie-informatio-content introduction">([^<]+)<', r, "")
953 967
         nfo["tagline"] = nfo["plot"]
954 968
         return nfo
955 969
 

+ 13
- 6
util.py View File

@@ -94,17 +94,17 @@ def nfo2desc(nfo):
94 94
             d = ""
95 95
         return d.encode("utf8") if isinstance(d, unicode) else d
96 96
 
97
-    desc += ddd("tagline")
98
-    if "plot" in nfo and "tagline" in nfo and nfo["tagline"] <> nfo["plot"]:
99
-        desc += ddd("plot")
100
-    elif "plot" in nfo and not "tagline" in nfo:
101
-        desc += ddd("plot")
102 97
     desc += ddd("genre","Genre")
103 98
     desc += ddd("runtime","Length")
104 99
     desc += ddd("director","Director")
105 100
     desc += ddd("actor","Actors")
106 101
     desc += ddd("language","Languages")
107 102
     desc += ddd("quality","Quality")
103
+    desc += ddd("tagline")
104
+    if "plot" in nfo and "tagline" in nfo and nfo["tagline"] <> nfo["plot"]:
105
+        desc += ddd("plot")
106
+    elif "plot" in nfo and not "tagline" in nfo:
107
+        desc += ddd("plot")
108 108
     return desc.encode("utf8") if isinstance(desc,unicode) else desc
109 109
 
110 110
 def nfo2title(nfo):
@@ -113,7 +113,14 @@ def nfo2title(nfo):
113 113
     title = nfo["title"]
114 114
     if "originaltitle" in nfo and nfo["originaltitle"] and nfo["originaltitle"]<>nfo["title"]:
115 115
         title +=" ~ "+nfo["originaltitle"]
116
-    if "year" in nfo and nfo["year"]:
116
+    se = ""
117
+    if "season" in nfo and nfo["season"]:
118
+        se += "S%s" % nfo["season"]
119
+    if "episode" in nfo and nfo["episode"]:
120
+        se += "E%s" % nfo["episode"]
121
+    if se:
122
+        title += " (%s)" % se
123
+    elif "year" in nfo and nfo["year"]:
117 124
         title += " (%s)"%nfo["year"]
118 125
     return title.encode("utf8") if isinstance(title,unicode) else title
119 126