Skip to content

Commit

Permalink
Improve ABC weather video url retrieval per Matt Huisman advice
Browse files Browse the repository at this point in the history
  • Loading branch information
bossanova808 committed Jun 6, 2023
1 parent e6158d7 commit 14cde23
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions resources/lib/abc/abc_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ def get_abc_weather_video_link():
json_object = json.loads(json_string.string)

# log(json_object)
# Put into: https://jsonhero.io/j/JU0I9LB4AlLU
# Put the json blob into: https://jsonhero.io/j/JU0I9LB4AlLU
# Gives a path to the needed video as:
# $.props.pageProps.channelpage.components.0.component.props.list.3.player.config.sources.1.file

url = json_object['props']['pageProps']['channelpage']['components'][0]['component']['props']['list'][3]['player']['config']['sources'][1]['file']
return url
# Rather than grab the URL directly (as place in array might change), grab all the available URLs and get the best quality from it
# See: https://github.com/bossanova808/weather.ozweather/commit/e6158d704fc160808bf66220da711805860d85c7
data = json_object['props']['pageProps']['channelpage']['components'][0]['component']['props']['list'][3]
urls = [x for x in data['player']['config']['sources'] if x['type'] == 'video/mp4']
return sorted(urls, key=lambda x: x['bitrate'], reverse=True)[0]['file']

except Exception as inst:
log("Couldn't get ABC video URL from scraped page: " + str(inst))
Expand Down

0 comments on commit 14cde23

Please sign in to comment.