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

datetime.datetime issue #55

Open
cosminadrianpopescu opened this issue Apr 19, 2020 · 5 comments
Open

datetime.datetime issue #55

cosminadrianpopescu opened this issue Apr 19, 2020 · 5 comments

Comments

@cosminadrianpopescu
Copy link

I'm trying to use script.module.youtube.dl in my own plugin like this:

addon.xml

<import addon="script.module.youtube.dl" version="20.324.0"/>

And then in my python file:

from YDStreamExtractor import getVideoInfo
info = getVideoInfo(id, 1)

This will give me an error in YoutubeDLWrapper.py at line 62:

File "/home/lixa/.kodi/addons/script.module.youtube.dl/lib/YDStreamExtractor.py", line 383, in getVideoInfo
    info = _getYoutubeDLVideo(url, quality, resolve_redirects)
File "/home/lixa/.kodi/addons/script.module.youtube.dl/lib/YDStreamExtractor.py", line 181, in _getYoutubeDLVideo
    r = ytdl.extract_info(url, download=False)
File "/home/lixa/.kodi/addons/script.module.youtube.dl/lib/youtube_dl/YoutubeDL.py", line 797, in extract_info
    ie_result = ie.extract(url)
File "/home/lixa/.kodi/addons/script.module.youtube.dl/lib/youtube_dl/extractor/common.py", line 530, in extract
    ie_result = self._real_extract(url)
File "/home/lixa/.kodi/addons/script.module.youtube.dl/lib/youtube_dl/extractor/youtube.py", line 2157, in _real_extract
    upload_date = unified_strdate(upload_date)
File "/home/lixa/.kodi/addons/script.module.youtube.dl/lib/youtube_dl/utils.py", line 2867, in unified_strdate
    upload_date = datetime.datetime.strptime(date_str, expression).strftime('%Y%m%d')
File "/home/lixa/.kodi/addons/script.module.youtube.dl/lib/YoutubeDLWrapper.py", line 62, in strptime
    return datetime.datetime(*(time.strptime(dstring, dformat)[0:6]))
AttributeError: type object 'datetime' has no attribute 'datetime'

In YoutubeDLWrapper.py, at line 62 there is this:

return datetime.datetime(*(time.strptime(dstring, dformat)[0:6]))

If I replace this with

return datetime(*(time.strptime(dstring, dformat)[0:6]))

Then it will be fine. I will get the info of the movie.

I didn't created a pull request because I don't know exactly why you have there datetime.datetime. I don't know what other implications are there. I don't use your plugin in any other way. But if you think that this wouldn't impact anything else, I can also open a pull request.

Thank you.

@cosminadrianpopescu
Copy link
Author

cosminadrianpopescu commented Apr 19, 2020

You can find my plugin here: https://gitlab.com/cosminadrianpopescu/plugin.video.invidious

Your plugin is called in file resources/lib/ytdl.py, line 10

@carlosgonz0
Copy link

HI there
Any solutions of it?

@b-jesch
Copy link

b-jesch commented Jul 24, 2020

The datetime.datetime issue can easy catched by including at line 62 in YoutubeDLWrapper.py

try:
    return datetime.datetime(*(time.strptime(dstring, dformat)[0:6]))
except AttributeError:
    return datetime(*(time.strptime(dstring, dformat)[0:6]))

@cosminadrianpopescu
Copy link
Author

Yes, of course. But again: what are the implications? I can have a pull request with this, if you think that this is ok.

@b-jesch
Copy link

b-jesch commented Jul 24, 2020

I know that you can abbretivave the use of datetime.datetime.function with

from datetime import datetime

so you end with datetime.strptime() instead of datetime.datetime.strptime(). May be there's some import statement anywhere. The fix don't touch the behavior of the original code so this can be included without side effects.

I know that a lot of people have a missfunction of youtube.dl (Attribute error whitin the Kodi logs), others for some reasons don't. Including the fix work for both. I suggest you make a pull request.

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

3 participants