不想总是动手翻看bt.ktxp.com内容,影响干别的事儿,在windows下的监控bt.ktxp.com新番的小程序
需要安装feedparser库 ,winsound ONLY FOR WIN//linuxer自行修改吧
import feedparser import re import winsound import time import os top = '' mystack = [] updated = False TAGS = {'1':['翠星', '奈亚子', ], '2':['革神语' ], '3':[], '4':['罪恶剪刀'], '5':['打工吧!魔王大人', '革命机', '恶魔幸存者', '恋爱物语', 'Oregairu', ], '6':['约会大作战', '超电磁炮',], '7':['绝对防卫', '巨人', '不笑猫', '我的妹妹'], } #key是星期X def get_cont(x): global top global mystack global updated r = re.compile('<.*?>') timestr = x.published flag = False for i in TAGS[str(time.localtime().tm_wday+1)]: if i.encode('utf8').decode('utf8') in x.title: flag = True break if flag == True: foo = r.sub('','['+timestr+']\n'+ x.title + '\n') foo += x['links'][1]['href'] mystack.append(foo) if updated == True: print(foo) print("------------------------------------------------") return (foo,timestr) return None def update(): global top global updated f = feedparser.parse("http://bt.ktxp.com/rss-sort-1.xml") #filter filtered = [] for i in f.entries: bar = get_cont(i) if bar != None: filtered.append(bar) updated = False timestr = filtered[0][1] #get published time #alerm if top != '' and top != timestr: winsound.Beep(6000,1000) os.system('cls') foobar = [i for i in filtered if i not in mystack] #get difference set for i in foobar: print(i) mystack.clear() #clear stack top = timestr #update latest time updated = True time.sleep(120) print('Updated!') elif top == '':#first time top = timestr updated = True print('Last Updated:' + top) while True: update() if not updated: time.sleep(10) #1min
share.dmhy.net也可以用,把xml换成http://share.dmhy.org/topics/rss/rss.xml即可( 我就是开两个……)
linux用户可以用一下pyaudio库,播放wav代码源自官方
./audio.py
# -*- coding: utf-8 -*- import pyaudio import wave chunk = 1024 def play(): wf = wave.open(r"./wave.wav", 'rb') p = pyaudio.PyAudio() stream = p.open(format = p.get_format_from_width(wf.getsampwidth()), channels = wf.getnchannels(), rate = wf.getframerate(), output = True) while True: data = wf.readframes(chunk) if data == "": break stream.write(data) stream.close() p.terminate()
调用的时候只需将
winsound.Beep(2000,3000)
替换成
import audio audio.play()