Browse Source

labojumi pēc instalēšanas

Ivars 5 years ago
parent
commit
dd2024f92d
4 changed files with 1000 additions and 747 deletions
  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 View File

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

+ 940
- 718
project.wpr
File diff suppressed because it is too large
View File


+ 25
- 11
sources/filmas.py View File

65
 
65
 
66
         if clist=="home":
66
         if clist=="home":
67
             content.extend([
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
             return content
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
         elif clist=="filmu-katalogs":
90
         elif clist=="filmu-katalogs":
78
             r=self.call(data)
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
             for item in result:
93
             for item in result:
81
                 title = item[2]+' (%s)'%item[3]
94
                 title = item[2]+' (%s)'%item[3]
82
                 data2 = item[0]
95
                 data2 = item[0]
83
-                img = self.url + item[1].replace("thumbs_m/","")
96
+                img = item[1]
84
                 desc = title
97
                 desc = title
85
                 content.append((title,self.name+"::"+data2,img,desc))
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
             if m:
100
             if m:
88
                 data2 = "filmu-katalogs/"+m.group(1)
101
                 data2 = "filmu-katalogs/"+m.group(1)
89
                 content.append(("Next page",self.name+"::"+data2, "","Next page"))
102
                 content.append(("Next page",self.name+"::"+data2, "","Next page"))
118
         phpsessid = r.cookies["PHPSESSID"]
131
         phpsessid = r.cookies["PHPSESSID"]
119
 
132
 
120
         ### Main playlist ###
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
         headers = headers2dict("""
136
         headers = headers2dict("""
124
 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0
137
 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0
125
 Accept: */*
138
 Accept: */*
152
 
165
 
153
             ### Key request ###
166
             ### Key request ###
154
             headers["Origin"] = "https://www.filmas.lv"
167
             headers["Origin"] = "https://www.filmas.lv"
168
+            headers["Referer"] = "https://www.filmas.lv/" + data
155
             headers["Cookie"] = 'filmassession=%s; PHPSESSID=%s' % (filmassession, phpsessid)
169
             headers["Cookie"] = 'filmassession=%s; PHPSESSID=%s' % (filmassession, phpsessid)
156
             #r=requests.get(url,headers=headers, verify=False)
170
             #r=requests.get(url,headers=headers, verify=False)
157
             #url_key = re.search('#EXT-X-KEY:METHOD=AES-128,URI="(.+?)"', r.content, re.IGNORECASE | re.MULTILINE).group(1)
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 View File

76
         if clist=="home":
76
         if clist=="home":
77
             content.extend([
77
             content.extend([
78
                 ("TV tiešraides", "ltc::tiesraide","","TV tiešraides"),
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
                 ("Meklēt", "ltc::search/{0}","","Meklēt visā saturā"), #TODO
85
                 ("Meklēt", "ltc::search/{0}","","Meklēt visā saturā"), #TODO
86
             ])
86
             ])
87
             return content
87
             return content
96
         ### Tiešraides ####
96
         ### Tiešraides ####
97
         elif data=="tiesraide":
97
         elif data=="tiesraide":
98
             now = dt2ts(dt.now())
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
             for item in self.get_channels():
101
             for item in self.get_channels():
101
                 title = item["attributes"]["title"]
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
                 for epg in epgs:
104
                 for epg in epgs:
104
                     if item["id"] == epg["relationships"]["channel"]["data"]["id"]:
105
                     if item["id"] == epg["relationships"]["channel"]["data"]["id"]:
105
                         epg = epg["attributes"]
106
                         epg = epg["attributes"]
122
                 content.append((title,self.name+"::"+data2,img,desc))
123
                 content.append((title,self.name+"::"+data2,img,desc))
123
             return content
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
             for item in r["data"]:
130
             for item in r["data"]:
129
                 title = item["attributes"]["title"]
131
                 title = item["attributes"]["title"]
130
                 data2 = item["links"]["self"][1:] + "?include=items"
132
                 data2 = item["links"]["self"][1:] + "?include=items"
134
             return content
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
         ### Arhīva kategorijas
151
         ### Arhīva kategorijas
138
         elif data=="archive/categories":
152
         elif data=="archive/categories":
139
             #https://manstv.lattelecom.tv/api/v1.3/get/archive/records/?filter[category]=13&limit=10&until_id=1458681019238
153
             #https://manstv.lattelecom.tv/api/v1.3/get/archive/records/?filter[category]=13&limit=10&until_id=1458681019238
635
         return streams
649
         return streams
636
 
650
 
637
     def is_video(self,data):
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
         if "get-stream" in data:
653
         if "get-stream" in data:
642
             return True
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
             return True
656
             return True
645
         elif cmd[0]=="arhivs" and len(cmd)==4:
657
         elif cmd[0]=="arhivs" and len(cmd)==4:
646
             return True
658
             return True
654
             return self.ch
666
             return self.ch
655
         #if not self.check_logedin():
667
         #if not self.check_logedin():
656
         #    self.login() # citādi nerāda TV3, LNT, TV6
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
         self.ch=[]
670
         self.ch=[]
659
         for i,item in enumerate(r["data"]):
671
         for i,item in enumerate(r["data"]):
660
             self.ch.append(item)
672
             self.ch.append(item)