Closed ocfox closed 1 year ago
That's what I thought, but pattern match seems to be a new feature in python 3.10? Does anyone have a better idea?
#!/usr/bin/env python3
import argparse
import douyu
import bilibili
# others
parser = argparse.ArgumentParser()
parser.add_argument("platform", help="直播平台")
parser.add_argument("room", help="直播间号码")
args = parser.parse_args()
match args.platform:
case "douyu":
print(douyu.DouYu(args.room).get_real_url())
case "bilibili":
print(bilibili.get_real_url(args.room))
#other case:
Using many cases is a bad way, maybe unified all scripts use {platform}.get_realurl(args.room))
is a good way.
If package
real-url
, use a unified command replacepython xxx.py
is a good way. E.g.:real-url douyu 12306
,real-url bilibili 11111
Maybe using a python script with Argparse and a simple modification to the way other scripts pass in the live room number. I will try this, once that's done, I'll open a pull request.