Phil 5 år sedan
förälder
incheckning
3aae27ec6f
1 ändrade filer med 32 tillägg och 7 borttagningar
  1. 32 7
      main.py

+ 32 - 7
main.py

@@ -1,9 +1,11 @@
 import auth as auth
+import os
 from getpass import getpass
 import requests
 from html.parser import HTMLParser
 from html.entities import name2codepoint
 from subprocess import call
+import subprocess
 
 def main():
     while True:
@@ -40,6 +42,22 @@ def main():
         if uin =='99':
             exit()
 
+def episode(sess,episode):
+    response = sess.get('https://proxer.me'+ep['link'])
+    content = response.content
+    epars = episodeParser()
+    epars.feed(str(content))
+    code = epars.code
+    link = "https://s3-psc.proxer.me/files/0/"+code+"/video.mp4"
+    print(link)
+    print('1 - open with vlc')
+    print('2 - download')
+    uin = input('$>: ')
+    if uin == '1':
+        call(["vlc", link])
+    if uin == '2':
+        call(['curl',link,'-o',ep['title']+'.mp4'])
+ 
 def episode_test():
     f = open('episode.html','r')
     content = f.readlines()
@@ -53,7 +71,9 @@ def episode_test():
     print('2 - download')
     uin = input('$>: ')
     if uin == '1':
-        call(["vlc", link])
+        os.popen('vlc '+link)
+        #x = subprocess.run(['bash','vlc',link])
+        #call(["vlc", link])
     if uin == '2':
         call(['curl',link,'-o','test.mp4'])
     
@@ -70,12 +90,14 @@ def LesezeichenAll(sess):
     print('Readlist')
     for i in range (0,len(readlist) - 1):
         print('r' + str(i) + ' - ' + readlist[i]['name'] + ' - ' + str(readlist[i]['new']))
-    print(str(readlist))
     uin = input('$>: ')
+    link = ""
     if uin[0] == 'w':
-        print(watchlist[int(uin.replace('w',''))]['link'])
+        ep = watchlist[int(uin.replace('w',''))]
     else:
-        print(readlist[int(uin.replace('r',''))]['link'])
+        ep = readlist[int(uin.replace('r',''))]
+    print(link)
+    episode(sess,ep)
 
 def LesezeichenSingle(sess,mode):
     response = sess.get('https://proxer.me/ucp?s=reminder&utm_source=nav#top')
@@ -119,10 +141,13 @@ def LesezeichenD():
         print('r' + str(i) + ' - ' + readlist[i]['name'] + ' - ' + str(readlist[i]['new']))
     print(str(readlist))
     uin = input('$>: ')
+    link = ''
     if uin[0] == 'w':
-        print(watchlist[int(uin.replace('w',''))]['link'])
+        link = watchlist[int(uin.replace('w',''))]['link']
     else:
-        print(readlist[int(uin.replace('r',''))]['link'])
+        link = readlist[int(uin.replace('r',''))]['link']
+    print(link)
+    
     
 class episodeParser(HTMLParser):
     inScript = False
@@ -189,7 +214,7 @@ class lesezeichenParser(HTMLParser):
                 self.anime['link'] = attrs[2][1]
 
         if self.inData and tag == 'img':
-            if 'online' in attrs[0]:
+            if 'online' in attrs[0][1]:
                 self.anime['new'] = True
             else:
                 self.anime['new'] = False