Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show.first_aired_date AttributeError: 'NoneType' object has no attribute 'split' errors #94

Open
caffeinatedMike opened this issue Oct 18, 2018 · 4 comments

Comments

@caffeinatedMike
Copy link

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?

@Forcide
Copy link
Contributor

Forcide commented Oct 18, 2018

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))

@caffeinatedMike
Copy link
Author

@Forcide Thanks for the tip & for confirming you're also seeing this issue. If you figured out a fix, why not submit a PR?

@Forcide
Copy link
Contributor

Forcide commented Oct 18, 2018

@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.

@caffeinatedMike
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants