main.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. import auth as auth
  2. import os
  3. from getpass import getpass
  4. import requests
  5. from subprocess import call
  6. import subprocess
  7. from parsers.episode import episodeParser
  8. from parsers.lesezeichen import lesezeichenParser
  9. def main():
  10. while True:
  11. print('PYrxoer Python wrapper for proxer.me')
  12. print('1 - Login')
  13. print('2 - Lesezeichen - All')
  14. print('3 - Lesezeichen - Anime')
  15. print('4 - Lesezeichen - Manga')
  16. print('5 - Lesezeichen - dummy')
  17. print('6 - Episode test')
  18. print('99 - exit')
  19. uin = input('$>: ')
  20. if uin == '1':
  21. user = input('username: ')
  22. pw = getpass('password:' )
  23. sess = auth.run(user,pw)
  24. if uin == '2':
  25. LesezeichenAll(sess)
  26. if uin == '3':
  27. LesezeichenSingle(sess,1)
  28. if uin == '4':
  29. LesezeichenSingle(sess,2)
  30. if uin == '5':
  31. LesezeichenD()
  32. if uin == '6':
  33. episode_test()
  34. if uin =='99':
  35. exit()
  36. def chapter_dummy(sess,ep):
  37. response = sess.get('https://proxer.me' + ep['link'])
  38. f = open('dummys/chapter.html','w')
  39. f.write(str(response.content))
  40. f.close()
  41. def episode(sess,episode):
  42. response = sess.get('https://proxer.me'+ep['link'])
  43. content = response.content
  44. epars = episodeParser()
  45. epars.feed(str(content))
  46. code = epars.code
  47. link = "https://s3-psc.proxer.me/files/0/"+code+"/video.mp4"
  48. print(link)
  49. print('1 - open with vlc')
  50. print('2 - download')
  51. uin = input('$>: ')
  52. if uin == '1':
  53. call(["vlc", link])
  54. if uin == '2':
  55. call(['curl',link,'-o',ep['title']+'.mp4'])
  56. def episode_test():
  57. f = open('dummys/episode.html','r')
  58. content = f.readlines()
  59. f.close()
  60. epars = episodeParser()
  61. epars.feed(str(content))
  62. code = epars.code
  63. link = "https://s3-psc.proxer.me/files/0/"+code+"/video.mp4"
  64. print(link)
  65. print('1 - open with vlc')
  66. print('2 - download')
  67. uin = input('$>: ')
  68. if uin == '1':
  69. os.popen('vlc '+link)
  70. #x = subprocess.run(['bash','vlc',link])
  71. #call(["vlc", link])
  72. if uin == '2':
  73. call(['curl',link,'-o','test.mp4'])
  74. def LesezeichenAll(sess):
  75. response = sess.get('https://proxer.me/ucp?s=reminder&utm_source=nav#top')
  76. lpars = lesezeichenParser()
  77. content = response.content
  78. lpars.feed(str(content))
  79. watchlist = lpars.watchlist
  80. readlist = lpars.readlist
  81. print('Watchlist')
  82. for i in range (0,len(watchlist) - 1):
  83. print('w' + str(i) + ' - ' + watchlist[i]['name'] + ' - ' + str(watchlist[i]['new']))
  84. print('Readlist')
  85. for i in range (0,len(readlist) - 1):
  86. print('r' + str(i) + ' - ' + readlist[i]['name'] + ' - ' + str(readlist[i]['new']))
  87. uin = input('$>: ')
  88. link = ""
  89. if uin[0] == 'w':
  90. ep = watchlist[int(uin.replace('w',''))]
  91. episode(sess,ep)
  92. else:
  93. ep = readlist[int(uin.replace('r',''))]
  94. chapter_dummy(sess,ep)
  95. print(link)
  96. def LesezeichenSingle(sess,mode):
  97. response = sess.get('https://proxer.me/ucp?s=reminder&utm_source=nav#top')
  98. lpars = lesezeichenParser()
  99. content = response.content
  100. lpars.feed(str(content))
  101. watchlist = lpars.watchlist
  102. readlist = lpars.readlist
  103. if mode == 1:
  104. print('Watchlist')
  105. plist = watchlist
  106. else:
  107. print('Readlist')
  108. plist = readlist
  109. for i in range (0,len(plist) - 1):
  110. print(str(i) + ' - ' + plist[i]['name'] + ' - ' + str(plist[i]['new']))
  111. uin = input('$>: ')
  112. link = plist[int(uin)]['link']
  113. url = 'https://proxer.me'+link
  114. print(link)
  115. print(url)
  116. f = open('episode.html','w')
  117. response = sess.get(url)
  118. f.write(str(response.content))
  119. f.close
  120. print('written')
  121. def LesezeichenD():
  122. lpars = lesezeichenParser()
  123. f = open('dump.html','r')
  124. content = f.readlines()
  125. lpars.feed(str(content))
  126. watchlist = lpars.watchlist
  127. readlist = lpars.readlist
  128. print('----------------------------')
  129. print('watchlist')
  130. for i in range (0,len(watchlist) - 1):
  131. print('w' + str(i) + ' - ' + watchlist[i]['name'] + ' - ' + str(watchlist[i]['new']))
  132. print('readlist')
  133. for i in range (0,len(readlist) - 1):
  134. print('r' + str(i) + ' - ' + readlist[i]['name'] + ' - ' + str(readlist[i]['new']))
  135. print(str(readlist))
  136. uin = input('$>: ')
  137. link = ''
  138. if uin[0] == 'w':
  139. link = watchlist[int(uin.replace('w',''))]['link']
  140. else:
  141. link = readlist[int(uin.replace('r',''))]['link']
  142. print(link)
  143. main()