| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- import auth as auth
- from tqdm import tqdm
- import pickle
- import os
- import configparser
- from getpass import getpass
- import requests
- from subprocess import call
- import subprocess
- from parsers.episode import episodeParser
- from parsers.lesezeichen import lesezeichenParser
- from parsers.chapter import chapterParser
- from parsers.player import playerParser
- from util.chromecast import ccast
- baseurl = ''
- if os.path.isfile('cookies'):
- f = open('cookies','rb')
- sess = requests.session()
- sess.cookies.update(pickle.load(f))
- def main():
- ReadConfig()
- print(config['paths']['anime_path'])
- while True:
- print('PYrxoer Python wrapper for proxer.me')
- print('0 - Load')
- print('1 - Login')
- print('2 - Lesezeichen - All')
- print('3 - Lesezeichen - Anime')
- print('4 - Lesezeichen - Manga')
- print('5 - Browse local')
- print('99 - exit')
- uin = input('$>: ')
-
- # auth.checkLogin()
- if uin == '0':
- if os.path.isfile(config['paths']['cookie_jar']):
- f = open(config['paths']['cookie_jar'],'rb')
- sess = requests.session()
- sess.cookies.update(pickle.load(f))
- if uin == '1':
- user = input('username: ')
- pw = getpass('password:' )
- sess = auth.login(user,pw,config)
- print(str(auth.token))
- f = open(config['paths']['cookie_jar'],'wb')
- pickle.dump(sess.cookies,f)
- if uin == '2':
- LesezeichenAll(sess)
- if uin == '3':
- LesezeichenSingle(sess,1)
- if uin == '4':
- LesezeichenSingle(sess,2)
- if uin =='99':
- exit()
- def chapter(sess,ep):
- url = baseurl + ep['link'].replace('chapter','read').replace('#top','')+'/1'
- response = sess.get(url)
- content = response.content
- chapPars = chapterParser()
- chapPars.images = []
- chapPars.feed(str(content))
- path = config['paths']['manga_path']+'/'+ep['name']+'/'+ep['num']+'/'
- if not os.path.exists(path):
- os.makedirs(path)
- print(str(ep))
- print(chapPars.serverurl)
- count = 0
- while True:
- print(ep['name'] + ' - ' + ep['num'])
- print('1 - Download')
- print('2 - mark as read')
- print('3 - go to next')
- print('4 - go to previous')
- print('5 - mark to read')
- print('6 - read local')
- print('7 - Details')
- print('99 - Back')
- uin = input('$>: ')
- if uin == '1':
- print(path)
- for p in tqdm(chapPars.images):
- #put https in front because changes from proxer?
- call(['curl','https://'+chapPars.serverurl + p['file'],'-o',path+str(count).zfill(2)+p['file'][p['file'].rindex('.'):]])
- #call(['curl',chapPars.serverurl + p['file'],'-o',path+str(count).zfill(2)+p['file'][p['file'].rindex('.'):]])
- count +=1
- if uin == '2':
- url = baseurl + ep['link'].replace('#top','?format=json&type=reminder&'+ chapPars.token +'=1&title=reminder_next')
- response = sess.post(url,data = {"check":1})
- print(str(response.content))
- if uin == '5':
- url = baseurl + ep['link'].replace('#top','?format=json&type=reminder&'+ chapPars.token +'=1&title=reminder_this')
- response = sess.post(url,data = {"check":1})
- print(str(response.content))
- if uin =='4':
- prev = ep
- linkParts = ep['link'].split('/')
- linkParts[3] = str(int(linkParts[3]) - 1)
- prev['link'] = '/'.join(linkParts)
- prev['num'] = str(int(prev['num'])-1)
- chapter(sess,prev)
-
- if uin =='3':
- prev = ep
- linkParts = ep['link'].split('/')
- linkParts[3] = str(int(linkParts[3]) +1)
- prev['link'] = '/'.join(linkParts)
- prev['num'] = str(int(prev['num'])+1)
- chapter(sess,prev)
- if uin =='6':
- call(['feh','-z','-S','name',path])
- if uin == '99':
- break
-
- def episode(sess,ep):
- response = sess.get(baseurl+ep['link'])
- content = response.content
- epars = episodeParser()
- epars.feed(str(content))
- code = epars.code
- #link = 'https:'+epars.url.replace('#',code)
- link = epars.url.replace('#',code)
- response = sess.get(link)
- ppars = playerParser()
- ppars.feed(str(response.content))
- link = ppars.url
- while True:
- print(ep['name'] + ' - ' + ep['num'])
- print('1 - open with vlc')
- print('2 - download')
- print('3 - mark as watched')
- print('4 - go to next')
- print('5 - go to previous')
- print('6 - Details')
- print('7 - Play on Chromecast')
- print('99 - Exit')
- path = 'anime/'+ep['name']+'/'
- if not os.path.exists(path):
- os.makedirs(path)
- uin = input('$>: ')
- if uin == '1':
- call(["vlc",'-f', link])
- if uin == '2':
- call(['curl',link,'-o',path+ep['num']+'.mp4'])
- if uin == '3':
- url = baseurl + ep['link'].replace('#top','?format=json&type=reminder&'+ epars.token +'=1&title=reminder_next')
- response = sess.post(url,data = {"check":1})
- print(str(response.content))
- if uin =='4':
- prev = ep
- linkParts = ep['link'].split('/')
- linkParts[3] = str(int(linkParts[3]) +1)
- prev['link'] = '/'.join(linkParts)
- prev['num'] = str(int(prev['num'])+1)
- episode(sess,prev)
- if uin == '7':
- #TODO improve discovery and multiple favorites
- cast = ccast(config['devices']['chromecast'])
- if len(cast.getCasts()) <= 0:
- print('no chromecast found')
- cast.play(link,cast.getCasts()[0])
- if uin == '99':
- break
-
- def LesezeichenAll(sess):
- watchlist = []
- readlist = []
- response = sess.get(config['urls']['base_url']+'/ucp?s=reminder&utm_source=nav#top')
- lpars = lesezeichenParser()
- lpars.watchlist = []
- lpars.readlist = []
- content = response.content
- lpars.feed(str(content))
- watchlist = lpars.watchlist
- readlist = lpars.readlist
- print('Watchlist')
- for i in range (0,len(watchlist) - 1):
- print('w' + str(i) + ' - ' + watchlist[i]['name'] + ' - ' + str(watchlist[i]['new']))
- print('Readlist')
- for i in range (0,len(readlist) - 1):
- print('r' + str(i) + ' - ' + readlist[i]['name'] + ' - ' + str(readlist[i]['new']))
- uin = input('$>: ')
- link = ""
- if uin[0] == 'w':
- ep = watchlist[int(uin.replace('w',''))]
- episode(sess,ep)
- else:
- ep = readlist[int(uin.replace('r',''))]
- chapter(sess,ep)
- print(link)
-
- def LesezeichenSingle(sess,mode):
- response = sess.get(config['urls']['base_url']+'/ucp?s=reminder&utm_source=nav#top')
- lpars = lesezeichenParser()
- content = response.content
- lpars.feed(str(content))
- watchlist = lpars.watchlist
- readlist = lpars.readlist
- if mode == 1:
- print('Watchlist')
- plist = watchlist
- else:
- print('Readlist')
- plist = readlist
- for i in range (0,len(plist) - 1):
- print(str(i) + ' - ' + plist[i]['name'] + ' - ' + str(plist[i]['new']))
- uin = input('$>: ')
- link = plist[int(uin)]['link']
- url = config['urls']['base_url']+link
- print(link)
- print(url)
- f = open('episode.html','w')
- response = sess.get(url)
- f.write(str(response.content))
- f.close
- print('written')
- def ReadConfig():
- global config
- global baseurl
- config = configparser.ConfigParser()
- config.read_file(open('settings.cfg'))
- baseurl = config['urls']['base_url']
-
- def ListLocal():
- anime = []
- manga = []
-
- main()
|