瀏覽代碼

LMT bildes izlabotas

TV3 nebūtu jālido ārā ja nav bildes
Ivars 7 年之前
父節點
當前提交
dc3c9c527c
共有 3 個檔案被更改,包括 417 行新增514 行删除
  1. 404
    511
      project.wpr
  2. 8
    1
      sources/lmt.py
  3. 5
    2
      sources/mtgplay.py

+ 404
- 511
project.wpr
文件差異過大導致無法顯示
查看文件


+ 8
- 1
sources/lmt.py 查看文件

@@ -86,6 +86,8 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
86 86
                 else:
87 87
                     m = re.search('<img src="([^"]+)', r2)
88 88
                     img = m.group(1) if m else ""
89
+                if img.startswith("//"):
90
+                    img = "http:" + img
89 91
                 m = re.search('<span class="playlist-overlay">([^<]+)</span>', r2)
90 92
                 overlay = m.group(1) if m else ""
91 93
                 m = re.search('<span class="badge badge-[^>]+>([^<]+)(<[^>]+>([^<]+))*</span>', r2, re.IGNORECASE)
@@ -145,6 +147,8 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
145 147
         if categories:
146 148
             tite = "%s [%s]"%(title,categories)
147 149
         img = re.search('<meta property="twitter:image" content="([^"]+)">', r, re.IGNORECASE | re.DOTALL).group(1)
150
+        if img.startswith("//"):
151
+            img = "http:" + img
148 152
         desc = title + "\n" + re.search('<meta property="og:description" content="([^"]+)">', r, re.IGNORECASE | re.DOTALL).group(1)
149 153
         m = re.search('file: "([^"]+)"', r, re.IGNORECASE)
150 154
         if m:
@@ -201,5 +205,8 @@ if __name__ == "__main__":
201 205
     import run
202 206
     source = Source()
203 207
     data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
204
-    run.run(source, data)
208
+    if len(sys.argv) > 2:
209
+        run.run_cli(source, data)
210
+    else:
211
+        run.run(source, data)
205 212
     sys.exit()

+ 5
- 2
sources/mtgplay.py 查看文件

@@ -14,7 +14,7 @@ except:
14 14
 #!/usr/bin/env python
15 15
 # coding=utf8
16 16
 import urllib2, urllib
17
-import datetime, re, sys
17
+import datetime, re, sys, os
18 18
 import ssl
19 19
 if "_create_unverified_context" in dir(ssl):
20 20
     ssl._create_default_https_context = ssl._create_unverified_context
@@ -94,7 +94,10 @@ class Source(SourceBase):
94 94
                     elif "name" in item:
95 95
                         title = item["name"]
96 96
                     #data2 = self.name+"::"+"%s/%s"%(clist,item["id"])
97
-                    img = item["_links"]["image"]["href"].replace("{size}",self.pic_size) if "image" in item["_links"] else ""
97
+                    img = item["_links"]["image"]["href"].replace("{size}",self.pic_size) \
98
+                        if "image" in item["_links"] and \
99
+                        "href" in item["_links"]["image"] and item["_links"]["image"]["href"]\
100
+                        else ""
98 101
                     desc = item["summary"] if "summary" in item and item["summary"] else ""
99 102
 
100 103
                     ### Video ###