Skip to content

Instantly share code, notes, and snippets.

@freyta
Created January 1, 2022 07:29
Show Gist options
  • Save freyta/335ec1223156b75e733345850fbe6f05 to your computer and use it in GitHub Desktop.
Save freyta/335ec1223156b75e733345850fbe6f05 to your computer and use it in GitHub Desktop.
import json
import requests
import re
import subprocess
# Show = WWE Raw
show = 1007
year = 2014
# Used for episode end points
episode_list = []
episode_title = []
start_point = []
end_point = []
event_url = []
my_terms = ['Punk', 'Heyman']
alphabet = ['a','b','c','d','e','f','g',
'h','i','j','k','l','m','n',
'o','p','q','r','s','t','u',
'v','w','x','y','z']
# Make our URL from the show and year needed
URL = "https://cdn.watch.wwe.com/api/filter/episodes?device=web_browser&showIds={}&year={}&page_size=53".format(show, year)
# Get our potential episodes from the URL above
year_url = requests.get(URL).json()
# Get the watch path
# i.e. /watch/Raw-6819
for episode in year_url.get("items"):
episode_list.append(episode.get("watchPath"))
print("{} - {}".format(episode.get("firstBroadcastDate"), episode.get("watchPath")))
# Now we will load every episode URL and search for requested wrestler(s)
for event in episode_list:
URL = "https://cdn.watch.wwe.com/api/page?path={}".format(event)
# Get our event into a readable JSON format
event_json = requests.get(URL).json()
# Now we search each milestone for our wrestler(s)
for milestone in event_json['entries'][0]['item']['relatedItems']:
for i in milestone['item']['customFields']:
for superstar in my_terms:
try:
if re.search(superstar, milestone['item']['customFields'].get(i),re.IGNORECASE):
title = milestone['item']['title']
air_date = event_json['entries'][0]['item']['firstBroadcastDate'][:10]
series_name = event_json['entries'][0]['title']
episode_title.append("{} {} - {}".format(air_date, series_name, title))
start_point.append(milestone['item']['customFields']['StartPoint'])
end_point.append(milestone['item']['customFields']['EndPoint'])
event_url.append(event)
except TypeError:
pass
for superstar in my_terms:
if re.search(superstar, milestone['item'].get('title'),re.IGNORECASE) and milestone['relationshipType'] != "superstar":
title = milestone['item']['title']
air_date = event_json['entries'][0]['item']['firstBroadcastDate'][:10]
series_name = event_json['entries'][0]['title']
episode_title.append("{} {} - {}".format(air_date, series_name, title))
start_point.append(milestone['item']['customFields']['StartPoint'])
end_point.append(milestone['item']['customFields']['EndPoint'])
event_url.append(event)
new_title = [i for n, i in enumerate(episode_title) if i not in episode_title[:n]]
new_start = [i for n, i in enumerate(start_point) if i not in start_point[:n]]
new_end = [i for n, i in enumerate(end_point) if i not in end_point[:n]]
z = []
for i,a,b,c in zip(new_title, new_start, new_end, event_url):
z.append(f"python3 main.py -st {a} -et {b} -of \"{i}\".mp4 -t {c}")
# Download the segment/match
subprocess.call(f"python3 main.py -st {a} -et {b} -of \"{i}\".mp4 -t {c}", shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment