Przeglądaj źródła

pilnveidots playeris u.c.

Ivars 7 lat temu
rodzic
commit
6c0ae30770
4 zmienionych plików z 920 dodań i 592 usunięć
  1. 648
    507
      project.wpr
  2. 232
    70
      run.py
  3. 3
    0
      sources/ltc.py
  4. 37
    15
      sources/replay.py

+ 648
- 507
project.wpr
Plik diff jest za duży
Wyświetl plik


+ 232
- 70
run.py Wyświetl plik

@@ -2,10 +2,10 @@
2 2
 # coding=utf8
3 3
 import sys, os, traceback
4 4
 from Tkinter import *
5
-try:
6
-    from ttk import *
7
-except:
8
-    pass
5
+#try:
6
+#    from ttk import *
7
+#except:
8
+#    pass
9 9
 import tkMessageBox as tkm
10 10
 import tkSimpleDialog as tkd
11 11
 
@@ -24,7 +24,7 @@ class Main(Frame):
24 24
 
25 25
     def __init__(self, sources, cfg_file="streams.cfg"):
26 26
         self.root = Tk()
27
-        self.root.geometry("1050x600")
27
+        self.root.geometry("1050x600+100+0")
28 28
         Frame.__init__(self, self.root)
29 29
         img = PhotoImage(file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icon.gif'))
30 30
         #img = PhotoImage(file= 'icon.gif')
@@ -104,7 +104,10 @@ class Main(Frame):
104 104
 
105 105
 
106 106
     def list_action(self, evt=None, key=None):
107
-        cs = int(self.listbox.curselection()[0])
107
+        try:
108
+            cs = int(self.listbox.curselection()[0])
109
+        except Exception as e:
110
+            cs = 0
108 111
         self.cur_index = cs
109 112
         if (not key) and evt:
110 113
             w = evt.widget
@@ -138,7 +141,7 @@ class Main(Frame):
138 141
                     self.show_content(self.cur, self.cur_index)
139 142
                     return
140 143
             else:
141
-                self.play_video(self.content[cs])
144
+                self.play_video(self.content[cs], select=0, show_info=True)
142 145
                 self.listbox.selection_set(self.cur_index)
143 146
                 self.listbox.activate(self.cur_index)
144 147
                 self.listbox.focus_set()
@@ -160,7 +163,13 @@ class Main(Frame):
160 163
             self.set_list_item(index2)
161 164
 
162 165
         elif key in ("i", "I"):
163
-            print "TODO - indo"
166
+            if self.sources.is_video(data):
167
+                self.play_video(self.content[cs], select=0, show_info=True)
168
+            else:
169
+                a = VideoInfo(self.content[cs]).result
170
+            self.listbox.selection_set(self.cur_index)
171
+            self.listbox.activate(self.cur_index)
172
+            self.listbox.focus_set()
164 173
 
165 174
     def set_list_item(self, index):
166 175
         self.cur_index = index
@@ -227,12 +236,15 @@ class Main(Frame):
227 236
             imagesprite = self.pic.create_image(200, 125,image=image)
228 237
             self.pic.image = image
229 238
 
230
-    def play_video(self, cur2):
239
+    def play_video(self, cur2, select=None, show_info=False):
231 240
         if self.sources.stream_type(cur2[1]):
232 241
             stream = util.item()
233 242
             stream["url"] = cur2[1]
234 243
             stream["name"] = cur2[0]
244
+            stream["desc"] = cur2[3]
245
+            stream["img"] = cur2[2]
235 246
             streams = [stream]
247
+            select = 0
236 248
         else:
237 249
             try:
238 250
                 streams = self.sources.get_streams(cur2[1])
@@ -244,16 +256,28 @@ class Main(Frame):
244 256
             if not streams:
245 257
                 tkm.showerror("Error getting streams", "No streams found")
246 258
                 return
247
-            if len(streams) > 1:
248
-                lst = []
249
-                for i,s in enumerate(streams):
250
-                    s =  {k:v.decode("utf8") if v and isinstance(v, str) else v for k,v in zip(s.keys(), s.values())}
251
-                    lst.append(("[%s,%s] %s"%(s["lang"],s["quality"],s["name"]),i))
252
-                a = ChoiceBox("ChoiceBox test", "Select stream", lst, parent=self, width=40).result
253
-                stream = streams[a]
259
+        if show_info: # Izsauc pilno Info logu
260
+            a = VideoInfo(cur2, streams).result
261
+            if a is None:
262
+                return
254 263
             else:
255
-                stream = streams[0]
256
-            play_stream(stream, self.tmp_path)
264
+                select = a
265
+        else:  # izvelās strimu no saraksta
266
+            if select is None:
267
+                if len(streams) > 1:
268
+                    lst = []
269
+                    for i,s in enumerate(streams):
270
+                        s =  {k:v.decode("utf8") if v and isinstance(v, str) else v for k,v in zip(s.keys(), s.values())}
271
+                        lst.append(("[%s,%s] %s"%(s["lang"],s["quality"],s["name"]),i))
272
+                    a = ChoiceBox("ChoiceBox test", "Select stream", lst, parent=self, width=120).result
273
+                    if a is not None:
274
+                        select = a
275
+                    else:
276
+                        return
277
+                else:
278
+                    select = 0
279
+        stream = streams[select]
280
+        play_stream(stream, self.tmp_path)
257 281
 
258 282
     def start(self):
259 283
         self.root.mainloop()
@@ -261,31 +285,35 @@ class Main(Frame):
261 285
 
262 286
 class ChoiceBox(tkd.Dialog):
263 287
     #a = ChoiceBox("ChoiceBox test", "Select stream", items, parent=self).result
264
-    def __init__(self, title, prompt, items, width=20, height=15,
288
+    def __init__(self, title, prompt, items, width=40, height=20,
265 289
                  initialvalue=0, parent = None):
266 290
         if not parent:
267 291
             import Tkinter
268 292
             parent = Tkinter._default_root
269 293
         self.prompt = prompt
270 294
         self.items = items
271
-        self.width = width
272
-        self.height = height
295
+        self.lwidth = width
296
+        self.lheight = height
273 297
         self.result = None
274 298
         self.initialvalue = initialvalue
275 299
         tkd.Dialog.__init__(self, parent, title)
276 300
 
277 301
     def body(self, master):
302
+        #self.width = 100
303
+        #self.height = 100
278 304
         w = Label(self, text=self.prompt, justify=LEFT)
279 305
         w.pack(side=TOP)
280 306
         frame1 = Frame(self)
281 307
         frame1.pack(side=TOP, fill=X, expand=1, padx=5)
282 308
         scrollbar = Scrollbar(frame1, orient=VERTICAL)
283
-        self.listbox = Listbox(frame1, yscrollcommand=scrollbar.set, width=self.width, height=self.height)
309
+        self.listbox = Listbox(frame1, yscrollcommand=scrollbar.set, width=self.lwidth, height=self.lheight)
284 310
         scrollbar.config(command=self.listbox.yview)
285 311
         #self.listbox.config(yscrollcommand=scrollbar.set)
286 312
         self.listbox.pack(side=LEFT, fill=BOTH, expand=1)
287 313
         scrollbar.pack(side=LEFT, fill=Y)
288 314
         for item in self.items:
315
+            if isinstance(item, list) or isinstance(item, tuple):
316
+                item = item[0]
289 317
             self.listbox.insert(END, item)
290 318
         self.listbox.selection_set(self.initialvalue)
291 319
         self.listbox.activate(self.initialvalue)
@@ -309,41 +337,158 @@ class ChoiceBox(tkd.Dialog):
309 337
     def apply(self):
310 338
         self.result = self.listbox.curselection()[0]
311 339
 
312
-class Info(tkd.Dialog):
340
+class VideoInfo(tkd.Dialog):
313 341
     #a = ChoiceBox("ChoiceBox test", "Select stream", items, parent=self).result
314
-    def __init__(self, title, items, width=20, height=15,
315
-                 initialvalue=0, parent = None):
342
+    def __init__(self, cur=None, streams=[], select=0, parent = None):
316 343
         if not parent:
317 344
             import Tkinter
318 345
             parent = Tkinter._default_root
319
-        self.prompt = prompt
320
-        self.items = items
321
-        self.width = width
322
-        self.height = height
346
+        self.streams = streams
347
+        self.subs = streams[0]["subs"] if len(streams) > 0 and "subs" in streams[0] else []
348
+        self.select = select
349
+        self.select2 = 0
350
+        self.cur = cur
351
+        if not streams:
352
+            self.name = cur[0]
353
+            self.data = cur[1]
354
+            self.img = cur[2]
355
+            self.desc = cur[3]
356
+        else:
357
+            self.name = streams[0]["name"]
358
+            self.data = cur[1]
359
+            self.img = streams[0]["img"]
360
+            self.desc = streams[0]["desc"]
361
+        self.picons_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "picons")
362
+        self.tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tmp")
323 363
         self.result = None
324
-        self.initialvalue = initialvalue
325
-        tkd.Dialog.__init__(self, parent, title)
364
+        tkd.Dialog.__init__(self, parent, self.title)
365
+
326 366
 
327 367
     def body(self, master):
328
-        w = Label(self, text=self.prompt, justify=LEFT)
368
+        # Virsraksts
369
+        self.title("Item information")
370
+        w = Label(self, text=self.name, justify=LEFT, font=("Tahoma", 14, "bold"))
329 371
         w.pack(side=TOP)
330
-        frame1 = Frame(self)
331
-        frame1.pack(side=TOP, fill=X, expand=1, padx=5)
332
-        scrollbar = Scrollbar(frame1, orient=VERTICAL)
333
-        self.listbox = Listbox(frame1, yscrollcommand=scrollbar.set, width=self.width, height=self.height)
334
-        scrollbar.config(command=self.listbox.yview)
335
-        #self.listbox.config(yscrollcommand=scrollbar.set)
336
-        self.listbox.pack(side=LEFT, fill=BOTH, expand=1)
337
-        scrollbar.pack(side=LEFT, fill=Y)
338
-        for item in self.items:
339
-            self.listbox.insert(END, item)
340
-        self.listbox.selection_set(self.initialvalue)
341
-        self.listbox.activate(self.initialvalue)
342
-        self.listbox.bind('<Double-1> ', self.list_select)
343
-        self.listbox.bind('<Key> ', self.list_key)
344
-        self.update()
345
-        self.geometry("+%d+%d"%(self.parent.winfo_rootx()+100, self.parent.winfo_rooty()+100 ))
346
-        return self.listbox
372
+        frame0 = Frame(self, width=820, height=600)  #, background="gray", borderwidth=2)
373
+        frame0.pack(side=TOP)
374
+
375
+        frame_l = Frame(frame0, width=410, height=600)  #, background="red", borderwidth=2)
376
+        frame_l.pack(side=LEFT)
377
+        frame_r = Frame(frame0, width=410, height=600)  #, background="green", borderwidth=2)
378
+        frame_r.pack(side=LEFT)
379
+
380
+        self.pic = Canvas(frame_l, width=400, height=400)
381
+        self.pic.pack(side=TOP, expand=1, padx=5, pady=5)
382
+        img = self.img
383
+        if img:
384
+            if not img.startswith("http"):
385
+                img_path = os.path.join(self.picons_path, img)
386
+                if img and os.path.exists(img_path):
387
+                    im =  Image.open(img_path)
388
+                else:
389
+                    im = None
390
+                    print "No image found ", img_path
391
+            elif img:
392
+                fcache = img.replace(":", "_").replace("/", "-").replace(":", "_")
393
+                fcache = os.path.join(self.tmp_path, fcache)
394
+                if os.path.exists(fcache):
395
+                    im =  Image.open(fcache)
396
+                else:
397
+                    r = requests.get(img)
398
+                    if r.status_code == 200:
399
+                        img_data = r.content
400
+                        im = Image.open(StringIO.StringIO(r.content))
401
+                        with open(fcache, "wb") as f:
402
+                            f.write(r.content)
403
+                    else:
404
+                        im = None
405
+            if im:
406
+                im.thumbnail((400, 400))
407
+                image = ImageTk.PhotoImage(im)
408
+                imagesprite = self.pic.create_image(200, 200,image=image)
409
+                self.pic.image = image
410
+
411
+        if self.streams or self.subs:
412
+            Label(frame_l, text="Streams (%s)" % len(self.streams), justify=LEFT).pack(side=TOP)
413
+            frame2 = Frame(frame_l, width=400, height=100)
414
+            frame2.pack(side=TOP, fill=X, expand=1, padx=5, pady=5)
415
+            scrollbar = Scrollbar(frame2, orient=VERTICAL)
416
+            self.listbox = Listbox(frame2, yscrollcommand=scrollbar.set, height=6)  #, width=40, height=10)
417
+            scrollbar.config(command=self.listbox.yview)
418
+            #self.listbox.config(yscrollcommand=scrollbar.set)
419
+            self.listbox.pack(side=LEFT, fill=BOTH, expand=1)
420
+            scrollbar.pack(side=LEFT, fill=Y)
421
+            lst = []
422
+            for i,s in enumerate(self.streams):
423
+                s =  {k:v.decode("utf8") if v and isinstance(v, str) else v for k,v in zip(s.keys(), s.values())}
424
+                item = "[%s,%s] %s"%(s["lang"],s["quality"],s["name"])
425
+                self.listbox.insert(END, item)
426
+            self.listbox.selection_set(self.select)
427
+            self.listbox.activate(self.select)
428
+            self.listbox.bind('<Double-1> ', self.list_select)
429
+            self.listbox.bind('<Key> ', self.list_key)
430
+            #self.listbox.bind('<<ListboxSelect>>', lambda evt: self.list_action(evt, "Changed"))
431
+            self.listbox.bind('<<ListboxSelect>>', lambda evt: self.list_changed(evt, "Changed"))
432
+
433
+            self.url_stream = Text(frame_l, height=1, width=10, font=("Tahoma", 10))
434
+            self.url_stream.pack(fill=X, expand=1, padx=5, pady=5)
435
+            self.url_stream.config(state=NORMAL)
436
+            self.url_stream.insert(END, self.streams[self.select]["url"])
437
+            self.url_stream.config(state=DISABLED)
438
+
439
+        frame_desc = Frame(frame_r, height=400, width=400)
440
+        frame_desc.pack(side=TOP, fill=X, expand=1, padx=5, pady=5)
441
+        scrollbar2 = Scrollbar(frame_desc)
442
+        desc = Text(frame_desc, height=25, width=55, wrap="word", yscrollcommand=scrollbar2.set)  #, borderwidth=0, highlightthickness=0)
443
+        scrollbar2.config(command=desc.yview)
444
+        scrollbar2.pack(side="right", fill="y")
445
+        desc.configure(font=("Tahoma", 10))
446
+        desc.pack(side=TOP)
447
+        desc.insert(END, self.desc)
448
+        desc.insert(END, "\n\n"+self.cur[1])
449
+        desc.insert(END, "\n"+self.cur[2])
450
+        desc.config(state=DISABLED)
451
+
452
+        if self.streams or self.subs:
453
+            Label(frame_r, text="Subtitles (%s)" % len(self.subs), justify=LEFT).pack(side=TOP)
454
+            frame_sub = Frame(frame_r, width=400, height=100)
455
+            frame_sub.pack(side=TOP, fill=X, expand=1, padx=5, pady=5)
456
+            scrollbar3 = Scrollbar(frame_sub, orient=VERTICAL)
457
+            self.listbox2 = Listbox(frame_sub, yscrollcommand=scrollbar3.set, height=6)  #, width=40, height=10)
458
+            scrollbar.config(command=self.listbox2.yview)
459
+            #self.listbox.config(yscrollcommand=scrollbar.set)
460
+            self.listbox2.pack(side=LEFT, fill=BOTH, expand=1)
461
+            scrollbar3.pack(side=LEFT, fill=Y)
462
+            for i,s in enumerate(self.subs):
463
+                item = ("%s - %s"%(s["lang"],s["name"])).encode("utf8")
464
+                self.listbox2.insert(END, item)
465
+            #self.listbox2.bind('<Double-1> ', self.list_select)
466
+            #self.listbox2.bind('<Key> ', self.list_key)
467
+            #self.listbox2.selection_set(self.select)
468
+            self.listbox2.bind('<<ListboxSelect>>', lambda evt: self.list_changed2(evt, "Changed"))
469
+
470
+            self.url_sub = Text(frame_r, height=1, width=10, font=("Tahoma", 10))
471
+            self.url_sub.pack(fill=X, expand=1, padx=5, pady=5)
472
+            if self.subs:
473
+                self.url_sub.config(state=NORMAL)
474
+                self.url_sub.insert(END, self.subs[self.select]["url"])
475
+            self.url_sub.config(state=DISABLED)
476
+
477
+
478
+        #self.update()
479
+        #self.geometry("+%d+%d"%(self.parent.winfo_rootx()+0, self.parent.winfo_rooty()+0 ))
480
+        #self.  geometry('+10+10')
481
+        return self.listbox if "listbox" in dir(self) else None
482
+
483
+    def buttonbox(self):
484
+        box = Frame(self)
485
+        w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE)
486
+        w.pack(side=LEFT, padx=5, pady=5)
487
+        w = Button(box, text="Cancel", width=10, command=self.cancel)
488
+        w.pack(side=LEFT, padx=5, pady=5)
489
+        self.bind("<Return>", self.ok)
490
+        self.bind("<Escape>", self.cancel)
491
+        box.pack()
347 492
 
348 493
     def list_key(self, evt):
349 494
         key = evt.keysym
@@ -353,6 +498,21 @@ class Info(tkd.Dialog):
353 498
         elif key == "Escape":
354 499
             self.cancel()
355 500
 
501
+    def list_changed(self, evt, key):
502
+        self.select =  evt.widget.curselection()[0]
503
+        self.url_stream.config(state=NORMAL)
504
+        self.url_stream.delete("1.0", END)
505
+        self.url_stream.insert(END, self.streams[self.select]["url"])
506
+        self.url_stream.config(state=DISABLED)
507
+
508
+    def list_changed2(self, evt, key):
509
+        self.select2 =  evt.widget.curselection()[0]
510
+        self.url_sub.config(state=NORMAL)
511
+        self.url_sub.delete("1.0", END)
512
+        self.url_sub.insert(END, self.streams[self.select2]["url"])
513
+        self.url_sub.config(state=DISABLED)
514
+
515
+
356 516
     def list_select(self, evt):
357 517
         self.ok()
358 518
 
@@ -360,6 +520,7 @@ class Info(tkd.Dialog):
360 520
         self.result = self.listbox.curselection()[0]
361 521
 
362 522
 
523
+
363 524
 def run(sources=None, data="config::home", title="Home", cfg_file="streams.cfg"):
364 525
     app = Main(sources, cfg_file=cfg_file)
365 526
     app.show_content((title, data, "", ""))
@@ -454,23 +615,23 @@ def run_cli(sources, data="config::home", title="Home", cfg_file="streams.cfg"):
454 615
             traceback.print_exc()
455 616
             raw_input("Continue?")
456 617
 
457
-def play_video(streams, select=False):
458
-    if len(streams)>1 and select:
459
-        for i,s in enumerate(streams):
618
+def play_video(streams, select=None):
619
+    if select is None:
620
+        if len(streams)>1:
621
+            for i,s in enumerate(streams):
460 622
 
461
-            print "%s: [%s,%s,%s] %s"%(i,s["quality"],s["lang"],s["type"],s["name"])
462
-        a = raw_input("Select stram to play: ")
463
-        try:
464
-            n = int(a)
465
-        except:
466
-            n = 0
467
-        if n>=len(streams):
468
-            stream = streams[-1]
623
+                print "%s: [%s,%s,%s] %s"%(i,s["quality"],s["lang"],s["type"],s["name"])
624
+            a = raw_input("Select stram to play: ")
625
+            try:
626
+                select = int(a)
627
+                if select>=len(streams):
628
+                    select = len(streams) - 1
629
+            except:
630
+                select = None
469 631
         else:
470
-            stream = streams[n]
471
-    else:
472
-        stream = streams[0]
473
-    play_stream(stream)
632
+            select = 0
633
+    if select is not None:
634
+        play_stream(streams[select])
474 635
 
475 636
 
476 637
 def play_stream(stream, tmp_path=""):
@@ -523,12 +684,13 @@ def player(url, title = "", subfile = "",headers={}, player="ffplay"):
523 684
     ]
524 685
     # gst-launch-1.0 -v souphttpsrc ssl-strict=false proxy=127.0.0.1:8888 extra-headers="Origin:adadadasd"  location="http://bitdash-a.akamaihd.net/content/sintel/sintel.mpd" ! decodebin! autovideosink
525 686
     cmd2 = [
526
-        r"C:\gstreamer\1.0\x86_64\bin\gst-launch-1.0","-v",
527
-        #"playbin", 'uri="%s"'%url,
528
-        "souphttpsrc", "ssl-strict=false",
529
-        "proxy=127.0.0.1:8888",
530
-        'location="%s"'%url,
531
-        '!decodebin!autovideosink'
687
+        r"C:\gstreamer\1.0\x86_64\bin\gst-launch-1.0",
688
+        #"-v",
689
+        "playbin", 'uri="%s"'%url,
690
+        #"souphttpsrc", "ssl-strict=false",
691
+        #"proxy=127.0.0.1:8888",
692
+        #'location="%s"'%url,
693
+        #'!decodebin!autovideosink'
532 694
     ]
533 695
 
534 696
     vf = r"drawtext=text='%{pts\:hms}':box=1:x=w-tw-10:y=h-th-10:boxcolor=black@0.5:fontsize=20:fontcolor=white"

+ 3
- 0
sources/ltc.py Wyświetl plik

@@ -316,6 +316,9 @@ Accept-Language: en-US,en;q=0.8
316 316
                     data2 += "?series" # TODO
317 317
                 img = "https://www.lattelecom.tv"+item["image"].encode("utf8")
318 318
                 desc = "%s\n%s"%(title,item["genre"].encode("utf8"))
319
+                if "is_premium" in item and item["is_premium"]:
320
+                    title = title + " [P]"
321
+                    desc = desc + "\nPremium"
319 322
                 content.append((title,self.name+"::"+data2,img,desc))
320 323
             m = re.search("page=(\d+)",data)
321 324
             if m:

+ 37
- 15
sources/replay.py Wyświetl plik

@@ -98,22 +98,29 @@ class Source(SourceBase):
98 98
 
99 99
         ### Tiešraides kanānālu saraksts
100 100
         elif path=="tiesraide":
101
-            url = "http://replay.lsm.lv/styles/main.css"
101
+            url2 = "http://replay.lsm.lv/styles/main.css"
102
+            r2= self._http_request(url2)
103
+            url = "http://replay.lsm.lv/lv/tiesraide/ltv1/"
104
+            # <div class="visible-xs">
102 105
             r= self._http_request(url)
103
-            for item in re.findall(r'channel-logo--(\w+)\{background-image:url\("([^"]+\.png)"', r):
104
-                ch = item[0]
106
+            i2 = r.find('<div class="visible-xs">')
107
+            result = re.findall(r"""onclick="RE.tools.navigate\('/lv/(tiesraide/\w+/)'\).+?<h5>([^<]+)</h5>.+?<time>([^<]+)</time>""", r[0:i2], re.DOTALL)
108
+            for item in result:
109
+                data2 = item[0]
110
+                ch = data2.split("/")[1]
105 111
                 title = ch.upper()
106
-                data2 = "tiesraide/%s/"%ch
107
-                img = "http://replay.lsm.lv"+item[1]
108
-                veids = "video "if "tv" in ch else "audio"
109
-                desc = title+" tiesraide (%s)"%veids
112
+                m = re.search(r'channel-logo--%s{background-image:url\("([^"]+)"\)' % ch, r2, re.DOTALL)
113
+                img = "http://replay.lsm.lv" + m.group(1)
114
+                desc = item[1]
115
+                # 00:10 &ndash; 00:45
116
+                desc = desc + " (%s)" % item[2].replace("&ndash;", "-")
110 117
                 content.append((title,self.name+"::"+data2,img,desc))
111 118
             return content
112 119
 
113 120
         ### Kanāla tiesraide
114 121
         elif clist == "tiesraide" and "/" in data:
115 122
             ch = data.split('/')[1]
116
-            veids = "video" if "tv" in ch else "audio"
123
+            veids = "audio" if "lr" in ch else "video"
117 124
             #url = "http://replay.lsm.lv/lv/tiesraide/ltv7/"
118 125
             url = "http://replay.lsm.lv/lv/tiesraide/%s/"%ch
119 126
             r= self._http_request(url)
@@ -142,6 +149,8 @@ class Source(SourceBase):
142 149
                 if not m:
143 150
                     raise Exception("No stream found")
144 151
                 url = m.group(1).replace('\\/', "/")
152
+                m = re.search('poster":"([^"]+)"', r, re.DOTALL)
153
+                img =  "http://ltv.lsm.lv" + m.group(1).replace("\\","") if m else ""
145 154
 
146 155
                 r = self._http_request(url,headers=headers)
147 156
                 m = re.search('"([^"]+m3u8[^"]+)"', r)
@@ -158,9 +167,10 @@ class Source(SourceBase):
158 167
                 if not m:
159 168
                     raise Exception("No stream found")
160 169
                 data2 = m.group(1).replace("\\","")
170
+                img = ""
171
+                desc = ""
161 172
 
162
-            img = ""
163
-            desc = ""
173
+            desc = title
164 174
             content =(title,data2,img,desc)
165 175
             return content
166 176
 
@@ -226,6 +236,18 @@ class Source(SourceBase):
226 236
             m = re.search('src="([^"]+)"></iframe>', r)
227 237
             if m:
228 238
                 url2 = m.group(1)
239
+                m = re.search('<meta property="og:title" content="([^"]+)"', r, re.DOTALL)
240
+                title = m.group(1)
241
+                m = re.search('<meta property="og:image" content="([^"]+)"', r, re.DOTALL)
242
+                img = m.group(1)
243
+                m = re.search('<meta property="og:description" content="([^"]+)"', r, re.DOTALL)
244
+                desc = m.group(1)
245
+                m = re.search('<div class="media-description">(.+)<div id="tab-comments">', r, re.DOTALL)
246
+                if m:
247
+                    rr = re.sub("<.+?>", " ", m.group(1))
248
+                    rr = re.sub("[\t\n]", " ", rr)
249
+                    desc =  re.sub(" {2,100}", " ", rr).strip()
250
+
229 251
                 headers = headers2dict("""
230 252
 User-Agent: Mozilla/5.0 (Linux; U; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
231 253
 Referer: http://replay.lsm.lv/lv/ieraksts/ltv/70398/tiesa-runa.-lielbritanija-gatavojas-referendumam-par-tu/
@@ -235,11 +257,11 @@ Referer: http://replay.lsm.lv/lv/ieraksts/ltv/70398/tiesa-runa.-lielbritanija-ga
235 257
                 if m:
236 258
                     data2 = m.group(1).replace("\\","")
237 259
                     m = re.search('"idstring":"([^"]+)', r2)
238
-                    title = m.group(1).strip() if m else ""
239
-                    title = title.decode("unicode-escape").encode("utf8")
240
-                    title = title.replace("\n","")
241
-                    img = ""
242
-                    desc = ""
260
+                    #title = m.group(1).strip() if m else ""
261
+                    #title = title.decode("unicode-escape").encode("utf8")
262
+                    #title = title.replace("\n","")
263
+                    #img = ""
264
+                    #desc = ""
243 265
                     if "youtube" in data2:
244 266
                         video_id = re.search(r"/watch\?v=([^&]+)",data2).group(1)
245 267
                         data2 = YouTubeVideoUrl().extract(video_id)