Ivars 5 лет назад
Родитель
Сommit
dd2024f92d
4 измененных файлов: 1000 добавлений и 747 удалений
  1. 7
    2
      playstreamproxy.py
  2. 940
    718
      project.wpr
  3. 25
    11
      sources/filmas.py
  4. 28
    16
      sources/ltc2.py

+ 7
- 2
playstreamproxy.py Просмотреть файл

@@ -110,6 +110,10 @@ class StreamHandler(BaseHTTPRequestHandler):
110 110
         #
111 111
         print "\n\n"+40*"#"+"\nget_url: \n%s" % self.path
112 112
         cmd, data, headers, qs = streamproxy_decode3(self.path)
113
+
114
+        print "cmd=", cmd,
115
+        print " data=", data
116
+        print_headers(qs)
113 117
         if KEY:
114 118
             key = qs["key"] if "key" in qs else ""
115 119
             if key <> KEY:
@@ -118,8 +122,7 @@ class StreamHandler(BaseHTTPRequestHandler):
118 122
                 self.write_error(404)
119 123
                 return
120 124
         if DEBUG:
121
-            print "cmd=%s"%cmd
122
-            print "Original request headers + url headers:"
125
+            print "=== Headers:"
123 126
             print_headers(self.headers.dict)
124 127
         self.protocol_version = 'HTTP/1.1'
125 128
         try:
@@ -219,6 +222,8 @@ class StreamHandler(BaseHTTPRequestHandler):
219 222
 
220 223
         headers2 = headers if headers else self.headers.dict
221 224
         headers2 = del_headers(headers2, ["host"])
225
+        # if ".ts" in url:
226
+        #    print url
222 227
         r = self.get_page_ses(url,ses,True,headers = headers2)
223 228
         code = r.status_code
224 229
         if not code in (200,206): # TODO 206 apstrāde!

+ 940
- 718
project.wpr
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 25
- 11
sources/filmas.py Просмотреть файл

@@ -65,25 +65,38 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
65 65
 
66 66
         if clist=="home":
67 67
             content.extend([
68
-                ("Meklēt", "filmas::filmu-katalogs/?mn={0}&tab=movies&sub_tab=movies-search","","Meklēt"),
69
-                ("Visas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-1","","Visur skatam visas filmas"),
70
-                ("Spēlfilmas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-1&mp20=112","","Visur skatamās spēlfilmas"),
71
-                ("Animācijas filmas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-1&mp20=113","","Visur skatamās animācijas filmas"),
72
-                ("Dokumentalās filmas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-1&mp20=111","","Visur skatamās dokumentalās filmas"),
73
-                ("Kinohronikas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-1&mp20=150","","Visur skatamās kinohronikas")    ,
68
+                ("Meklēt", "filmas::lmdb/api/search/?term={0}","","Meklēt"),
69
+                ("Visas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-all&watch=latvia&pg=1","","Latvijā skatamās visas filmas"),
70
+                ("Spēlfilmas", "filmu-katalogs/?tab=movies&sub_tab=movies-all&mp20=112&watch=latvia&pg=1","","Latvijā skatamās spēlfilmas"),
71
+                ("Dokumentalās filmas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-hronika&pg=1","","Latvijā skatamās kinohronikas")    ,
72
+                ("Animācijas filmas", "filmu-katalogs/?tab=movies&sub_tab=movies-all&mp20=113&watch=latvia&pg=1","","Latvijā skatamās animācijas filmas"),
73
+                ("Kinohronikas", "filmas::filmu-katalogs/filmu-katalogs/?tab=movies&sub_tab=movies-hronika","","Latvijā skatamās kinohronikas")    ,
74
+                ("Pēc alfabēta", "filmas::filmu-katalogs/?ml=A&tab=movies&sub_tab=movies-abc&pg=1","","Latvija skatamās filmas pēc alfabēta")    ,
74 75
             ])
75 76
             return content
76 77
 
78
+        elif "api/search" in data:
79
+            r = self.call(data)
80
+            js = json.loads(r)
81
+            for it in js:
82
+                if "type" in it and it["type"] == "movie":
83
+                    title = it["label"] + "(%s)" % it["year"] if "year" in it else ""
84
+                    img = ("https://www.filmas.lv/images/movies/" + it["photo"]) if "photo" in it and it["photo"] else ""
85
+                    desc = title
86
+                    data2 = "movie/%s" % it["value"]
87
+                    content.append((title,self.name+"::"+data2,img,desc))
88
+            return content
89
+
77 90
         elif clist=="filmu-katalogs":
78 91
             r=self.call(data)
79
-            result = re.findall(r'<a href="/(movie/\d+)">.+?<img src="/([^"]+)">.+?Pieejama.+?<div class="katalogs-filma-teksts">\s*(.+?)\s*<span style="font-weight:normal; ">\((\d+)\)</span>', r, re.DOTALL)
92
+            result = re.findall(r'<a href="/(movie/\d+)">.+?src="([^"]+)".+?"movie-catalog-title">([^<]+)<.+?"movie-catalog-year">([^<]+)<', r, re.DOTALL)
80 93
             for item in result:
81 94
                 title = item[2]+' (%s)'%item[3]
82 95
                 data2 = item[0]
83
-                img = self.url + item[1].replace("thumbs_m/","")
96
+                img = item[1]
84 97
                 desc = title
85 98
                 content.append((title,self.name+"::"+data2,img,desc))
86
-            m = re.search(r"<a class='pagenum' href='(\?tab=movies&sub_tab=movies-view-2[^']+)'>&gt;</a>", r, re.DOTALL)
99
+            m = re.search("<a class='next' href='(.+?)'", r, re.DOTALL)
87 100
             if m:
88 101
                 data2 = "filmu-katalogs/"+m.group(1)
89 102
                 content.append(("Next page",self.name+"::"+data2, "","Next page"))
@@ -118,8 +131,8 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
118 131
         phpsessid = r.cookies["PHPSESSID"]
119 132
 
120 133
         ### Main playlist ###
121
-        hid = re.search('src: "/lmdb/hls/playlist/(\w+).m3u8"', r.content).group(1)
122
-        url = "https://www.filmas.lv/lmdb/hls/playlist/%s.m3u8"%hid
134
+        m = re.search('lmdb.video_src = "/(.+?m3u8)"', r.content)
135
+        url = "https://www.filmas.lv/%s"%m.group(1)
123 136
         headers = headers2dict("""
124 137
 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0
125 138
 Accept: */*
@@ -152,6 +165,7 @@ Referer: https://www.filmas.lv/movie/%s/
152 165
 
153 166
             ### Key request ###
154 167
             headers["Origin"] = "https://www.filmas.lv"
168
+            headers["Referer"] = "https://www.filmas.lv/" + data
155 169
             headers["Cookie"] = 'filmassession=%s; PHPSESSID=%s' % (filmassession, phpsessid)
156 170
             #r=requests.get(url,headers=headers, verify=False)
157 171
             #url_key = re.search('#EXT-X-KEY:METHOD=AES-128,URI="(.+?)"', r.content, re.IGNORECASE | re.MULTILINE).group(1)

+ 28
- 16
sources/ltc2.py Просмотреть файл

@@ -76,12 +76,12 @@ Accept-Language: en-US,en;q=0.8
76 76
         if clist=="home":
77 77
             content.extend([
78 78
                 ("TV tiešraides", "ltc::tiesraide","","TV tiešraides"),
79
-                ("TV arhīvs", "ltc::arhivs","","TV arhīvs atseviškiem kanāliem"),
80
-                ("Bērnu", "ltc::videonoma/bernu","","Videonomas bērnu filmas un seriāli"),
81
-                ("Filmas", "ltc::videonoma/filmas","","Videonomas filmas"),
82
-                ("Premiere filmas", "ltc::videonoma/premiere","","Videonomas premiere filmas"),
83
-                ("Seriāli", "ltc::videonoma/series","","Videonomas seriāli"),
84
-                ("360 Play", "ltc::videonoma/360play","","Videonomas lattelecom saturs"),
79
+                ("TV arhīvs", "ltc::pages/archive","","TV arhīvs atseviškiem kanāliem"),
80
+                ("Bērnu", "ltc::pages/kids","","Videonomas bērnu filmas un seriāli"),
81
+                ("Filmas", "ltc::pages/films","","Videonomas filmas"),
82
+                ("Premiere filmas", "ltc::pages/premiere","","Videonomas premiere filmas"),
83
+                ("Seriāli", "ltc::pages/series","","Videonomas seriāli"),
84
+                ("360 Play", "ltc::/pages/360-play","","Videonomas lattelecom saturs"),
85 85
                 ("Meklēt", "ltc::search/{0}","","Meklēt visā saturā"), #TODO
86 86
             ])
87 87
             return content
@@ -96,10 +96,11 @@ Accept-Language: en-US,en;q=0.8
96 96
         ### Tiešraides ####
97 97
         elif data=="tiesraide":
98 98
             now = dt2ts(dt.now())
99
-            epgs = self.call("content/epgs/?filter[utFrom]=%s&filter[utTo]=%s&include=channel&page[size]=1000" % (now, now))["data"]
99
+            r = self.call("epgs/?filter[utFrom]=%s&filter[utTo]=%s&include=channel&page[size]=1000" % (now, now))
100
+            epgs = r["data"]
100 101
             for item in self.get_channels():
101 102
                 title = item["attributes"]["title"]
102
-                data2 = "content/live-streams/%s?include=quality"%item["id"]
103
+                data2 = "live-streams/%s?include=quality"%item["id"]
103 104
                 for epg in epgs:
104 105
                     if item["id"] == epg["relationships"]["channel"]["data"]["id"]:
105 106
                         epg = epg["attributes"]
@@ -122,9 +123,10 @@ Accept-Language: en-US,en;q=0.8
122 123
                 content.append((title,self.name+"::"+data2,img,desc))
123 124
             return content
124 125
 
125
-        ### TV arhīva sākums ###
126
-        elif data=="archive" or data=="arhivs":
127
-            r = self.call("pages/archive/?include=items,items.item")
126
+
127
+        ### Pages ###
128
+        elif clist=="pages" or data=="arhivs":
129
+            r = self.call(data+"?page[size]=1000")
128 130
             for item in r["data"]:
129 131
                 title = item["attributes"]["title"]
130 132
                 data2 = item["links"]["self"][1:] + "?include=items"
@@ -134,6 +136,18 @@ Accept-Language: en-US,en;q=0.8
134 136
             return content
135 137
 
136 138
 
139
+        ### Kategorija ###
140
+        elif clist=="categories" and len(plist) > 1:
141
+            r = self.call(data)
142
+            for item in r["items"]:
143
+                title = item["name"]
144
+                data2 = "archive/records?filter[category]=%s&limit=40"%item["id"]
145
+                img = "https://manstv.lattelecom.tv/"+ item['image']
146
+                desc = title
147
+                content.append((title,self.name+"::"+data2,img,desc))
148
+            return content
149
+
150
+
137 151
         ### Arhīva kategorijas
138 152
         elif data=="archive/categories":
139 153
             #https://manstv.lattelecom.tv/api/v1.3/get/archive/records/?filter[category]=13&limit=10&until_id=1458681019238
@@ -635,12 +649,10 @@ Accept-Language: en-US,en;q=0.8
635 649
         return streams
636 650
 
637 651
     def is_video(self,data):
638
-        if "::" in data:
639
-            data = data.split("::")[1]
640
-        cmd = data.split("/")
652
+        source, data, path, plist, clist, params, qs = self.parse_data(data)
641 653
         if "get-stream" in data:
642 654
             return True
643
-        elif cmd[0] in ("content") and cmd[1] in ("live-streams","record-streams","vod-streams", "catchup"):
655
+        if clist in ("live-streams","record-streams","vod-streams", "catchup"):
644 656
             return True
645 657
         elif cmd[0]=="arhivs" and len(cmd)==4:
646 658
             return True
@@ -654,7 +666,7 @@ Accept-Language: en-US,en;q=0.8
654 666
             return self.ch
655 667
         #if not self.check_logedin():
656 668
         #    self.login() # citādi nerāda TV3, LNT, TV6
657
-        r= self.call("content/channels?page[size]=1000&&filter[state]=1")
669
+        r= self.call("channels?page[size]=1000&&filter[state]=1")
658 670
         self.ch=[]
659 671
         for i,item in enumerate(r["data"]):
660 672
             self.ch.append(item)