-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more features & refactor the config part
- Loading branch information
Showing
7 changed files
with
125 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/python | ||
#coding=utf-8 | ||
import json | ||
|
||
class Config(object): | ||
|
||
data = {} | ||
cookies = {} | ||
|
||
def __init__(self, path): | ||
self.read(path) | ||
|
||
def read(self, path): | ||
|
||
with open(r'config.txt','r') as f: | ||
s = f.read() | ||
self.data = json.loads(s) | ||
|
||
with open(r'cookie.txt','r') as f: | ||
s = f.read() | ||
if 'cookie:' == s[:7]: s = s[7:] # do strip | ||
try: | ||
for line in s.split(';'): | ||
name, value = line.strip().split('=', 1) | ||
self.cookies[name] = value | ||
except Exception, e: | ||
print 'warning! please set correct cookies into \'cookie.txt\'', e | ||
|
||
if __name__ == '__main__': | ||
config = Config("config.txt") | ||
print config.data["90012"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"90012": { | ||
"GiftResponse": true, | ||
"ShowTime": false, | ||
"SmallTVHint": true, | ||
"MacNotification": true, | ||
"MacTTS": true, | ||
"DanmakuColor": "blue" | ||
}, | ||
"30040": { | ||
"GiftResponse": false, | ||
"ShowTime": false, | ||
"SmallTVHint": false, | ||
"MacNotification": false, | ||
"MacTTS": true | ||
}, | ||
"207919": { | ||
"GiftResponse": true, | ||
"ShowTime": false, | ||
"SmallTVHint": true, | ||
"MacNotification": false, | ||
"MacTTS": false | ||
} | ||
} |