forked from kakuyuuki/6v_auto_seed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrss_parse.py
More file actions
27 lines (27 loc) · 977 Bytes
/
Copy pathrss_parse.py
File metadata and controls
27 lines (27 loc) · 977 Bytes
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
from bs4 import BeautifulSoup
import re
import requests
class dmhy_rss(object):
def __init__(self):
self.url = 'https://share.dmhy.org/topics/rss/rss.xml'
self.rule = ''
self.rss = ''
self.title = ''
self.episode = ''
self.magneturl = ''
def get_rss(self):
r = requests.get(self.url, timeout=60)
self.rss = BeautifulSoup(r.content, 'xml')
def get_magnet(self):
title = self.rss.find('title', text=self.rule)
self.title = title
magneturl = title.parent.enclosure.attrs['url']
self.magneturl = magneturl
return magneturl
def get_episode(self):
dmhy_rule = re.compile('[^0-9s]([0-9][0-9])[^0-9bitp月][^bitp月]', re.I)
results = re.findall(dmhy_rule, self.title.text)
try:
self.episode = results[0]
except IndexError as Argument:
print('Error in getting episode\n', Argument)