PyTrakt
PyTrakt copied to clipboard
show.first_aired_date AttributeError: 'NoneType' object has no attribute 'split' errors
I'm trying to get the first_aired_date of episodes as I loop through MyShowCalendar and I keep consistently receiving the following error in my logs
File "C:\Users\mhill\AppData\Roaming\.homeassistant\deps\Python37\site-packages\trakt\tv.py", line 579, in first_aired_date
return airs_date(self.first_aired)
File "C:\Users\mhill\AppData\Roaming\.homeassistant\deps\Python37\site-packages\trakt\utils.py", line 31, in airs_date
parsed = airs_at.split('-')[:-1]
AttributeError: 'NoneType' object has no attribute 'split'
To produce the error I'm simply doing the following
import trakt
from trakt.calendar import MyShowCalendar
trakt.core.OAUTH_TOKEN = token
trakt.core.CLIENT_ID = config[CONF_CLIENT_ID]
trakt.core.CLIENT_SECRET = config[CONF_CLIENT_SECRET]
upcoming_data = MyShowCalendar(days=config[CONF_DAYS])
if not upcoming_data:
_LOGGER.error("Nothing in calendar")
for show in upcoming_data:
if not show:
continue
print(str(show.first_aired_date))
Any idea on how this can be fixed?
Hi @caffeinatedMike
I found something strange, it looks like when getting the TVEpisode object from the calender, certain property's are not being registered.
When remaking the TVEpisode object with the info provided from the calendar I was able to use first_aired_date.
Please note, just a workaround:
from trakt.tv import TVEpisode
for show in upcoming_data:
if not show:
continue
show_list = show.ext.split('/')
show_object = TVEpisode(show_list[1], show_list[3], show_list[5])
print(str(show_object.first_aired_date))
@Forcide Thanks for the tip & for confirming you're also seeing this issue. If you figured out a fix, why not submit a PR?
@caffeinatedMike No problem. I don't really found a fix, too new to this. But it looks like it has something to do with the _build of the TVEpisode, I could also be very wrong.
I'll give it a look over tomorrow and see if I can fix it given the starting info you gave me. Hopefully Ill be able to send a PR to fix it if all goes well tomorrow (and I'm not too busy)