-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathEopScorePageItem.py
47 lines (42 loc) · 1.44 KB
/
EopScorePageItem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os.path
# 一篇谱子的抽象类
class EopPageItem(object):
def __init__(self, strid,url, date,title,author):
self.strid = str(strid)
self.id = int(strid)
self.url = str(url)
self.date = str(date)
self.title = str(title)
self.author = str(author)
# 五线谱地址
self.staveUrl = 'http://www.everyonepiano.cn/Stave-'+str(self.id)+'.html'
self.staveImgs = []
# 简谱地址
self.numberUrl = 'http://www.everyonepiano.cn/Number-'+str(self.id)+'.html'
self.numberImgs = []
def print_attrs(self):
print(
'id:', self.id, ',',
'url:', self.url, ',',
'date:', self.date, ',',
'title:', self.title, ',',
'author:', self.author, ',',
)
# 获取存储路径
def getSavePath(self, parentdir):
# 文件夹取个长名字,免得重复了
path = os.path.join(parentdir, self.rep(self.title) + " (" + self.rep(self.author) + ")_" + self.strid)
return path
def rep(self,val):
# 去掉特殊字符 懒得写正则
v = val.replace("|", "")
v = v.replace(":", "")
v = v.replace("<", "")
v = v.replace(">", "")
v = v.replace("?", "")
v = v.replace("*", "")
v = v.replace("/", "")
v = v.replace("\\", "")
v = v.replace("\r", "")
v = v.replace("\n", "")
return v.strip()