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

Feature request: Check the publication date of a video & set limit by date #25

Open
reitmanjeff opened this issue Feb 8, 2023 · 1 comment

Comments

@reitmanjeff
Copy link

It would be nice to have this feature when getting videos from a channel.

video['publishedTimeText']['simpleText']

will return some strings like "13 days ago" or "2 weeks ago" but the result will change over time.
Also, there are some issues when converting text to date.

Is there a way to check the publication date of a video while running get_channel function?

@twissell-
Copy link
Contributor

Hey! I'd also like this to be implemented, but after looking at the code I'm not sure is possible. The function parses the "Videos" tab and the published date is not there (or at least I couldn't find it).

For my use case, I've solved the issue with this workaround:

import os
from datetime import datetime


def fuzzy_date_parser(fuzzy_date: str):
    date_format = "%Y-%m-%d %H:%M:%S"
    process = os.popen(f"date -d '{fuzzy_date}' '+{date_format}' 2>&1")

    exit_status = os.wait()[1]
    output = process.read()
    if exit_status != 0:
        raise ValueError(f"Error parsing '{fuzzy_date}'. {output}")

    return datetime.strptime(output[:19], date_format)

Note that is just a wrapper of the linux date command. It won't work on windows, but maybe is useful to you.

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