tonycpsu / streamglob

A console media browser designed to facilitate live and time-shifted viewing of online content.
GNU General Public License v3.0
34 stars 10 forks source link

Filename Template issues #52

Closed tampa-bay closed 3 years ago

tampa-bay commented 3 years ago

Fresh install on linux with python3.9. When using the template as template: "{provider_id}.{start_date_time}.{away_team.abbreviation}@{home_team.abbreviation}.{ext}" I get the error: streamglob.exceptions.SGInvalidFilenameTemplate: 'str' object has no attribute 'abbreviation'. Verbose output is as follows:

2021-07-11 21:15:57 [          _cache:158 ] [   debug] reading /home/user/.cache/python-entrypoints/52fe2c562e765480aee264face602f447b7225690d0c846f43cecf4561fa2d7b
2021-07-11 21:15:57 [       extension:219 ] [   debug] found extension EntryPoint(name='instagram', value='streamglob.providers.instagram:InstagramProvider', group='streamglob.providers')
2021-07-11 21:15:57 [       extension:219 ] [   debug] found extension EntryPoint(name='mlb', value='streamglob.providers.mlb:MLBProvider', group='streamglob.providers')
2021-07-11 21:15:57 [         columns:126 ] [   debug] column type, width: weight, 1
2021-07-11 21:15:57 [         columns:126 ] [   debug] column title, width: weight, 1
2021-07-11 21:15:57 [         columns:126 ] [   debug] column inning, width: given, 5
2021-07-11 21:15:57 [       extension:219 ] [   debug] found extension EntryPoint(name='nhl', value='streamglob.providers.nhl:NHLProvider', group='streamglob.providers')
2021-07-11 21:15:57 [         columns:126 ] [   debug] column period, width: given, 3
2021-07-11 21:15:57 [         columns:126 ] [   debug] column period_time, width: given, 5
2021-07-11 21:15:57 [       extension:219 ] [   debug] found extension EntryPoint(name='rss', value='streamglob.providers.rss:RSSProvider', group='streamglob.providers')
2021-07-11 21:15:57 [       extension:219 ] [   debug] found extension EntryPoint(name='twitch', value='streamglob.providers.twitch:TwitchProvider', group='streamglob.providers')
2021-07-11 21:15:57 [       extension:219 ] [   debug] found extension EntryPoint(name='youtube', value='streamglob.providers.youtube:YouTubeProvider', group='streamglob.providers')
2021-07-11 21:15:57 [         columns:126 ] [   debug] column media_listing_id, width: weight, 1
2021-07-11 21:15:57 [         columns:126 ] [   debug] column feed, width: given, 30
2021-07-11 21:15:57 [         columns:126 ] [   debug] column created, width: given, 19
2021-07-11 21:15:57 [         columns:126 ] [   debug] column media_type, width: given, 4
2021-07-11 21:15:57 [         columns:126 ] [   debug] column title, width: weight, 1
2021-07-11 21:15:57 [        dropdown:638 ] [   debug] select: All
2021-07-11 21:15:57 [         columns:126 ] [   debug] column media_listing_id, width: weight, 1
2021-07-11 21:15:57 [         columns:126 ] [   debug] column feed, width: given, 30
2021-07-11 21:15:57 [         columns:126 ] [   debug] column created, width: given, 19
2021-07-11 21:15:57 [         columns:126 ] [   debug] column title, width: weight, 1
2021-07-11 21:15:57 [        dropdown:638 ] [   debug] select: All
2021-07-11 21:15:57 [         columns:126 ] [   debug] column media_listing_id, width: weight, 1
2021-07-11 21:15:57 [         columns:126 ] [   debug] column feed, width: given, 30
2021-07-11 21:15:57 [         columns:126 ] [   debug] column created, width: given, 19
2021-07-11 21:15:57 [         columns:126 ] [   debug] column duration, width: given, 8
2021-07-11 21:15:57 [         columns:126 ] [   debug] column title, width: weight, 1
2021-07-11 21:15:57 [        dropdown:638 ] [   debug] select: All
2021-07-11 21:15:58 [        __main__:537 ] [   debug] streamglob starting
2021-07-11 21:15:58 [             bam:1935] [   debug] getting schedule: 1, None, 2021-07-05, 2021-07-05, None, None, None
2021-07-11 21:15:58 [             bam:1963] [   debug] http://statsapi.mlb.com/api/v1/schedule?sportId=1&startDate=2021-07-05&endDate=2021-07-05&gameType=&gamePk=&teamId=&hydrate=linescore,team,game(content(summary,media(epg),editorial(preview,recap),highlights(highlights(items))))
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633386
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633380
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633361
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633411
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633353
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633487
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633412
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633400
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633363
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633389
2021-07-11 21:15:59 [             bam:1045] [   debug] geting media for game 633378
2021-07-11 21:15:59 [             bam:1935] [   debug] getting schedule: 1, None, 2021-07-05, 2021-07-05, None, 112, None
2021-07-11 21:15:59 [             bam:1963] [   debug] http://statsapi.mlb.com/api/v1/schedule?sportId=1&startDate=2021-07-05&endDate=2021-07-05&gameType=&gamePk=&teamId=112&hydrate=linescore,team,game(content(summary,media(epg),editorial(preview,recap),highlights(highlights(items))))
2021-07-11 21:15:59 [           tasks:232 ] [   debug] task_manager starting
2021-07-11 21:15:59 [             bam:2288] [   debug] milestones: {'Start': 3, 'T1': 344, 'B1': 753, 'T2': 1711, 'B2': 2244, 'T3': 2709, 'B3': 3158, 'T4': 4119, 'B4': 4643, 'T5': 5102, 'B5': 6082, 'T6': 6654, 'B6': 8035, 'T7': 8561, 'B7': 9055, 'T8': 9600, 'B8': 11292, 'T9': 11972, 'B9': 12654, 'Live': None}
2021-07-11 21:15:59 [           model:402 ] [   error] Traceback (most recent call last):

  File "/home/user/.local/lib/python3.9/site-packages/streamglob/model.py", line 387, in expand_template
    outfile = s.format_map(
AttributeError: 'str' object has no attribute 'abbreviation'
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.9/site-packages/streamglob/model.py", line 387, in expand_template
    outfile = s.format_map(
AttributeError: 'str' object has no attribute 'abbreviation'
2021-07-11 21:04:00 [         widgets:189 ] [ warning] filename template is invalid: 'str' object has no attribute 'abbreviation'
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.9/site-packages/streamglob/model.py", line 387, in expand_template
    outfile = s.format_map(
AttributeError: 'str' object has no attribute 'abbreviation'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/bin/streamglob", line 8, in <module>
    sys.exit(main())
  File "/home/user/.local/lib/python3.9/site-packages/streamglob/__main__.py", line 554, in main
    rc = run_cli(action, provider, selection, **opts)
  File "/home/user/.local/lib/python3.9/site-packages/streamglob/__main__.py", line 477, in run_cli
    state.event_loop.run_until_complete(run_tasks(tasks))
  File "/home/user/.local/lib/python3.9/site-packages/nest_asyncio.py", line 70, in run_until_complete
    return f.result()
  File "/usr/lib/python3.9/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/usr/lib/python3.9/asyncio/tasks.py", line 256, in __step
    result = coro.send(None)
  File "/home/user/.local/lib/python3.9/site-packages/streamglob/__main__.py", line 447, in run_tasks
    async for task in tasks:
  File "/home/user/.local/lib/python3.9/site-packages/streamglob/providers/base.py", line 494, in download
    for task in self.create_download_tasks(listing, index=index, **kwargs):
  File "/home/user/.local/lib/python3.9/site-packages/streamglob/providers/widgets.py", line 187, in create_download_tasks
    filename = source.download_filename(**kwargs, listing=listing)
  File "/home/user/.local/lib/python3.9/site-packages/streamglob/model.py", line 416, in download_filename
    template_file = expand_template(template_file, safe=True)
  File "/home/user/.local/lib/python3.9/site-packages/streamglob/model.py", line 403, in expand_template
    raise SGInvalidFilenameTemplate(str(e))
streamglob.exceptions.SGInvalidFilenameTemplate: 'str' object has no attribute 'abbreviation'

Changing the template to template: "{provider_id}.{start_date_time}.{away_team}@{home_team}.{ext}" : produces streamlink downloading a file literally named: {provider_id}.{start_date_time}.{away_team}@{home_team}.mp4

I'm sure there's something I've screwed up with a dependency, but even doing a pip3 install --upgrade --force-reinstall --no-cache doesn't fix it.

tonycpsu commented 3 years ago

What branch are you on? For the main branch where current development is happening, template should be:

"mlb.{listing.start_date_time}.{listing.away_team.abbreviation}@{listing.home_team.abbreviation}.{ext}"

tonycpsu commented 3 years ago

...and yes, that's not what's in the sample config right now. Will fix.

tampa-bay commented 3 years ago

That would be it, thanks! Figured it was something I missed.