Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

Commit

Permalink
reformat project
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsmh committed Sep 23, 2019
1 parent 3d47478 commit eb9416b
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ __pycache__/
*.ini
build/
dist/
Pipfile
Pipfile.lock
5 changes: 1 addition & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

![](misc/screenshoot.jpg)

## yiban-api
易班API的使用是为了更方便地使用Python进行网页接口的调用。

## License
GPLv3

## Credit
Copyright © 2017-2018 simonsmh
Copyright © 2017-2018 simonsmh
File renamed without changes.
5 changes: 5 additions & 0 deletions ybapi/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## ybapi

易班API的使用是为了更方便地使用Python进行网页接口的调用。

此处为旧文件,大部分接口可用,但不再进行单独维护,亦未进行模块打包。
2 changes: 1 addition & 1 deletion yb.py → ybapi/yb.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import ybvote
import ybtopic
#import ybfeed
from yblogin import BASEURL, getUserToken, getInfo
from .yblogin import BASEURL, getUserToken, getInfo

r = requests.Session()

Expand Down
2 changes: 1 addition & 1 deletion ybfeed.py → ybapi/ybfeed.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# coding=utf-8
import requests as r
from yblogin import BASEURL
from .yblogin import BASEURL


class feed:
Expand Down
13 changes: 9 additions & 4 deletions yblogin.py → ybapi/yblogin.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def getUserToken(user, passwd, captcha=None):
'keysTime': KeysTime,
'is_rember': 1
}

LoginURL = r.post(LOGIN_URL, headers=header, data=data, timeout=10)
try:
token = LoginURL.cookies['yiban_user_token'] # -> KeyError Exception
Expand All @@ -61,9 +61,14 @@ def getUserToken(user, passwd, captcha=None):

def getInfo(token):

Get_Group_Info = requests.get(BASEURL+'my/group/type/public', cookies=token, timeout=10)
group_id = re.search(r'href="/newgroup/indexPub/group_id/(\d+)/puid/(\d+)"', Get_Group_Info.text).group(1)
puid = re.search(r'href="/newgroup/indexPub/group_id/(\d+)/puid/(\d+)"', Get_Group_Info.text).group(2)
try:
Get_Group_Info = requests.get(BASEURL+'my/group/type/public', cookies=token, timeout=10)
group_id = re.search(r'href="/newgroup/indexPub/group_id/(\d+)/puid/(\d+)"', Get_Group_Info.text).group(1)
puid = re.search(r'href="/newgroup/indexPub/group_id/(\d+)/puid/(\d+)"', Get_Group_Info.text).group(2)
except AttributeError:
Get_Group_Info = requests.get(BASEURL+'my/group/type/create', cookies=token, timeout=10)
group_id = re.search(r'href="/newgroup/indexPub/group_id/(\d+)/puid/(\d+)"', Get_Group_Info.text).group(1)
puid = re.search(r'href="/newgroup/indexPub/group_id/(\d+)/puid/(\d+)"', Get_Group_Info.text).group(2)

payload = {
'puid': puid,
Expand Down
2 changes: 1 addition & 1 deletion ybtopic.py → ybapi/ybtopic.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# coding=utf-8
import requests as r
from yblogin import BASEURL
from .yblogin import BASEURL


class topic:
Expand Down
2 changes: 1 addition & 1 deletion ybvote.py → ybapi/ybvote.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import time
import requests as r
from yblogin import BASEURL
from .yblogin import BASEURL


class vote:
Expand Down
12 changes: 5 additions & 7 deletions ybqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import random
import requests
import traceback
import ybvote
import ybtopic
from yblogin import BASEURL, getInfo
from ybapi import ybvote, ybtopic, yblogin
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets, QtNetwork
from ybqtmainui import Ui_mainWindow
from ybqtloginui import Ui_LoginWindow
Expand Down Expand Up @@ -80,7 +78,7 @@ def fprint(self, string, dlevel=0, num=0):
def login(self):
try:
self.sig.emit(self.fprint("易班 Token: " + self.token['yiban_user_token'], dlevel=1))
self.info = getInfo(self.token)
self.info = yblogin.getInfo(self.token)
self.group_id = self.info["group_id"]
self.puid = self.info["puid"]
self.channel_id = self.info["channel_id"]
Expand All @@ -96,8 +94,8 @@ def login(self):

def getEPGA(self):
try:
Get_EPGA = r.get(BASEURL + "newgroup/indexPub/group_id/" +
self.group_id + "/puid/" + self.puid, cookies=self.token, timeout=10)
Get_EPGA = r.get(yblogin.BASEURL + "newgroup/indexPub/group_id/" +
self.group_id + "/puid/" + self.puid, headers=yblogin.header, cookies=self.token, timeout=10)
EPGA = re.search(r"EGPA:[0-9\.]*", Get_EPGA.text)
self.epgasig.emit(EPGA.group())
except:
Expand Down Expand Up @@ -435,7 +433,7 @@ def showLogin(self):
loginw.show()

class LoginWindow(QtWidgets.QMainWindow, Ui_LoginWindow):

def __init__(self):
super(LoginWindow, self).__init__()
self.setupUi(self)
Expand Down

0 comments on commit eb9416b

Please sign in to comment.