-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgetclip.py
36 lines (29 loc) · 1.02 KB
/
getclip.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
from app import grabber
from app import clip
from app import output
import argparse
import json
import requests
import sys
#Generate parser arguments
parser = argparse.ArgumentParser(description="twitch Clip chat data grabber")
parser.add_argument("-s","--slug", metavar="", required=True, help="Twitch clib slug i.e. HungryOnerousCoffeeFrankerZ", type=str)
parser.add_argument("-i","--clientid", metavar="", required=True, help="your client id", type=str)
parser.add_argument("-f","--format", metavar="", help="json or console", type=str)
args = parser.parse_args()
#api id
cid = args.clientid
slug = args.slug
o_format = args.format
#get clip metadata
data = clip.getClipData(args.clientid, args.slug)
if data == None:
sys.exit("your client id is broken\ncheck your client id")
elif data == "wrongslug":
sys.exit("slug is broken\ncheck clip slug (link)")
print()
streamer_name = data["broadcaster"]["name"]
grabber.getChat(cid,data,args.format)
output.writetofile(o_format,slug,streamer_name)
print("\nsaving "+slug)
print("DONE!")