Skip to content

Commit

Permalink
提交
Browse files Browse the repository at this point in the history
  • Loading branch information
biancangming committed Dec 23, 2020
1 parent eb77c87 commit c4967f0
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/wtv.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions m3uMaker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# m3u文件解析脚本

支持批量检测.m3u在线文件,并输出可用的直播源

# URL 合集
`urls`输入可用的m3u直播地址
```javascript
urls = [

]
```
39 changes: 39 additions & 0 deletions m3uMaker/pareser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import requests
import random
from time import sleep
from m3u_parser import M3uParser


def sleep_random():
"""随机等待5-10秒防止IP被封"""
sleep_s = random.randint(1, 10)
sleep(sleep_s)


def check_url_ok(url):
"""检测连接是否可用"""
useragent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
print("正在检查URL %s" % url)
try:
result = requests.get(url, headers={"User-Agent": useragent}, timeout=10)
return result.status_code == 200
except requests.exceptions.ConnectionError as e:
print("URL %s 访问超时" % url)
return False


# URL 合集
urls = [
"https://raw.fastgit.org/qwerttvv/Beijing-IPTV/master/IPTV-Unicom.m3u"
]

m3u_playlist = M3uParser()

for url in urls:
m3u_playlist.parse_m3u(url)
m3u_list = map(lambda item: {"name": item.get("name", ""), "url": item.get("url", "")}, m3u_playlist.get_list())
for m in m3u_list:
sleep_random()
if not check_url_ok(m.get("url")):
continue
print("{name},{url}".format(name=m.get("name"), url=m.get("url", "")))
14 changes: 14 additions & 0 deletions m3uMaker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
aiohttp==3.7.3
async-timeout==3.0.1
asyncio==3.4.3
attrs==20.3.0
certifi==2020.12.5
chardet==3.0.4
idna==2.10
m3u-parser==0.1.1
multidict==5.1.0
pycountry==20.7.3
requests==2.25.0
typing-extensions==3.7.4.3
urllib3==1.26.2
yarl==1.6.3

0 comments on commit c4967f0

Please sign in to comment.