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

Video data #9

Closed
DrRonne opened this issue Jul 9, 2020 · 4 comments
Closed

Video data #9

DrRonne opened this issue Jul 9, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@DrRonne
Copy link

DrRonne commented Jul 9, 2020

Hello, thank you for making this library, it is awesome and works great!

One addition I would suggest, is to make something that can check video data before you download the video. For example, I only want to download videos that are shorter than one minute. Right now I would have to download it and check the time afterwards. It would be cool if I could check this beforehand.

@elmoiv
Copy link
Owner

elmoiv commented Jul 9, 2020

Thanks @DrRonne for your Ideas. I will consider these features in my next update.
Stay tuned!

@elmoiv elmoiv added the enhancement New feature or request label Jul 9, 2020
@bcornw2
Copy link

bcornw2 commented Jul 9, 2020

if you can afford the temporary disk space and the runtime speed, you can do what I do and check the size of the file after download, then delete it if its the wrong size, or move it to the correct location if its good to go. I know its not optimal but it was only like 2 extra loc after the initial call, and adds like 2 seconds per operation.

@elmoiv
Copy link
Owner

elmoiv commented Jul 9, 2020

I found a workaround for viewing video size and duration before downloading.
I am implementing it now so you can decide a maximum size or duration so if the targeted video quality does not meet the requirements passed, It will return with error number instead.

Here is a piece of my current work:

...
        self.duration = getDuration(self.page)
        self.size = int(
                    self.head(
                                self.video,
                                _proxies=self.proxies
                            ).headers['Content-Length']
                        )
...

The corresponding attributes will be max_d and max_s:

...
   def __init__(
               ...
                max_d=1e1000,
                max_s=1e1000,
               ...
                ):
        ...
        self.max_d, self.max_s = max_d, max_s
        ...
...

Stay tuned :)

@elmoiv
Copy link
Owner

elmoiv commented Jul 9, 2020

Published v1.0.9:

  • Added the ability to disable logging.
  • Maximum video size can be set.
  • Maximum video duration can be set.

To download videos shorter than 1 minute do the following:

from redvid import Downloader

reddit = Downloader()
reddit.max_d = 60  # 60 seconds
# more than 3 minutes video example
reddit.url = 'https://www.reddit.com/r/PublicFreakout/comments/ho5ml9/former_judges_michael_conahan_and_mark_ciavarella/'
reddit.download()

Now if the video exceeds 1 minutes, nothing will be downloaded and function will return error number corresponding to duration which equals 1.

@elmoiv elmoiv closed this as completed Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants