forked from lalifeier/IPTV
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.py
38 lines (31 loc) · 1.27 KB
/
main.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
import argparse
import asyncio
import logging
from iptv.hotel import Hotel
from iptv.udpxy import UDPxy
logger = logging.getLogger(__name__)
async def main():
parser = argparse.ArgumentParser(description="IP fetching and playlist generation script")
parser.add_argument("--ip", action="store_true", help="Fetch valid IPs")
parser.add_argument("--playlist", action="store_true", help="Generate playlists from valid IPs")
parser.add_argument("--rtp", action="store_true", help="Init rtp")
parser.add_argument("--type", choices=["hotel", "udpxy"], required=True, help="Type of IP to process")
args = parser.parse_args()
if args.rtp:
await UDPxy().init_rtp()
return
if args.ip:
if args.type == "hotel":
await Hotel().sniff_ip()
elif args.type == "udpxy":
await UDPxy().sniff_ip()
elif args.playlist:
if args.type == "hotel":
await Hotel().generate_playlist()
elif args.type == "udpxy":
await UDPxy().generate_playlist()
else:
logging.error("You must specify an action: --ip or --playlist.")
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
asyncio.run(main())