Skip to content

Commit

Permalink
Change approach to ABC video - scrape URL on demand when button click…
Browse files Browse the repository at this point in the history
…ed, then play (with appropriate name/thumb). This ensures URL is always up to date when they click the button - without this, the url can change inbetween weather updates, and playback then fails.
  • Loading branch information
bossanova808 committed May 31, 2023
1 parent e620a28 commit 2dfc2cd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Binary file added resources/ABC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions resources/lib/abc/abc_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
from resources.lib.store import Store
from resources.lib.common import *


def scrape_and_play_abc_weather_video():
"""
On-demand scrape the current ABC video URL and then play it back, with appropriate metadata/art etc.
"""
url = get_abc_weather_video_link()
# Construct an offscreen list item with metadata...
item = xbmcgui.ListItem(path=url)
item.setProperty('mimetype', 'video/mpeg')
item.setInfo('Video', { 'title' : 'ABC Weather In 90 Seconds'})
item.setArt({'thumb': f'{CWD}/resources/ABC.png'})
# ...and then play it, fullscreen
xbmc.Player().play(url, item, False)
pass


# See bottom of this file for notes on matching the video links (& Store.py for the regex)
def get_abc_weather_video_link():

Expand Down
7 changes: 7 additions & 0 deletions resources/lib/ozweather.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from .locations import *
# noinspection PyPackages
from .bom.bom_location import *
# noinspection PyPackages
from .abc.abc_video import *


def run(args):
Expand All @@ -25,6 +27,11 @@ def run(args):
if args[1].startswith('Location'):
find_bom_location()

# RUN MODE - ADDON CALLED FORM Kodi SETTINGS
# the addon is being called from the settings section where the user enters their postcodes
elif args[1].startswith('ABC'):
scrape_and_play_abc_weather_video()

# RUN MODE - GET WEATHER OBSERVATIONS AND FORECAST
# script is being called in general use, not from the settings page
# sys.argv[1] has the current location number (e.g. '1'), so fetch the weather data
Expand Down

0 comments on commit 2dfc2cd

Please sign in to comment.