Coder Social home page Coder Social logo

elmoiv / redvid Goto Github PK

View Code? Open in Web Editor NEW
108.0 6.0 15.0 3.66 MB

Smart downloader for Reddit hosted videos

License: GNU General Public License v3.0

Python 99.86% Batchfile 0.14%
reddit reddit-video video video-downloader downloader download-videos python bypassing

redvid's Introduction


Redvid icon
Redvid

Smart Downloader for Reddit Hosted Videos


Now available for Android*

Features

  • Download local hosted videos with audio.
  • Requires only requests and FFmpeg.
  • Ability to decide quality.
  • Bypass bot detection.

Installation

redvid requires Python 3.

Use pip to install the package from PyPI:

pip install redvid

Or, install the latest version of the package from GitHub:

pip install git+https://github.com/elmoiv/redvid.git

Usage

Using redvid to download a video:

> redvid -u "https://v.redd.it/c8oic7ppc2751" -mxq
  • via scripts:
from redvid import Downloader

reddit = Downloader(max_q=True)
reddit.url = 'https://v.redd.it/c8oic7ppc2751'
reddit.download()

or

__import__('redvid').Downloader(url='https://v.redd.it/c8oic7ppc2751', max_q=True).download()

Installing FFmpeg

Windows:

https://m.wikihow.com/Install-FFmpeg-on-Windows

(You may need to restart your pc after applying these steps)

Linux:

sudo apt install ffmpeg

Mac OS:

  • install Homebrew:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  • Then:

    $ brew install ffmpeg

Tests

Here are a few sample tests:

Console Commands

> redvid --help

usage: redvid [-h] [-u URL] [-p PATH] [-o] [-mxq] [-mnq] [-mxd MAXDURATION]
              [-mxs MAXSIZE] [-am] [-ad] [-px PROXIES] [-v] [-c]

Argument parser for redvid module

required arguments:
  -u URL, --url URL     Post URL for Reddit hosted video

optional arguments:
  -p PATH, --path PATH  Custom path for downloaded videos
  -o, --overwrite       Overwrite existing videos and ignore exception
  -mxq, --maxquality    Auto select maximum quality
  -mnq, --minquality    Auto select minimum quality
  -fn FILENAME, --filename FILENAME
                        Set custom filename for downloaded video
  -mxd MAXDURATION, --maxduration MAXDURATION
                        Ignore videos that exceed this duration (in seconds)
  -mxs MAXSIZE, --maxsize MAXSIZE
                        Ignore videos that exceed this size (in bytes)
  -am, --automax        Automatically download video with maximum size (Helps
                        for old reddit videos with unknown qualities)
  -ad, --autodir        Automatically create path if correctly typed and does
                        not exist
  -px PROXIES, --proxies PROXIES
                        Download videos through proxies for blocked regions
  -v, --version         Show redvid version
  -nc, --noclean        Don't clean temp folder after download is done

Stargazers over time

Stargazers over time

Contributing

Please contribute! If you want to fix a bug, suggest improvements, or add new features to the project, just open an issue or send me a pull request.

*Android version of Redvid is not open-source.

redvid's People

Contributors

bagdaja avatar denver-code avatar e-g-c avatar elmoiv avatar mwargan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

redvid's Issues

Sometimes, video is downloaded without audio

Describe the bug
Audio is not present in some videos downloaded. I am unsure if this is similar to other issues, since this happens for every 6-7 videos on my end. I have ffmpeg installed and am currently using macOS.

To Reproduce
Steps to reproduce the behavior:

video_path = f"assets/temp/{reddit_id}"
video_name = f"{name_normalize(reddit_title)[:251]}"
reddit = Downloader(max_q=True)
reddit.url = reddit_object["thread_url"]
reddit.path = video_path
reddit.filename = video_name
reddit.download()

video_full_path = f"{video_path}/{video_name}.mp4"

Videos that were downloaded without audio:
https://www.reddit.com/r/perfectlycutscreams/comments/hgpvd1/playing_uno_with_the_family_be_like/
https://www.reddit.com/r/perfectlycutscreams/comments/e0qiye/student_hides_under_desk_and_grabs_teachers_ankle/

Expected behavior
Reddit video saved as an .mp4 with audio

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS Monterey
  • Browser: Chrome(?)
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

path should be used before url to work correctly?

First time writing something in github, let me know if I did any mistake. not sure how to change the label to documentation.

I noticed that path should be added before url for it to work as required, it would be great to include anywhere either in documentation or in example code as it doesn't strike immediately to be a problem when dubbing the program when it doesn't save file to given path.

Don't use os.chdir()

Describe the bug
i trying to make a script and it either relies on os.getcwd() or "./"
"./" doesnt work since i get a WinError 3 "Path doesnt exists" from the downloader
and os.getcwd() works once but if run it again (with while or for loop or run the downloader multiple times in a scrip) your module changes the working directory to the given path to the downloader.

To Reproduce
Steps to reproduce the behavior:

  1. use path = "os.getcwd() + "\Download" to get a path.
  2. set path with reddit.path = path
  3. download a video.
    4 now os.getcwd() returns the path C:\(runningdirectory\Download\ resulting in a recursion each time a video is downloaded.

Expected behavior
not getting a recursion

Desktop (please complete the following information):

  • OS: Windows (will happen with any os)

Additional context
it works if you dont set the path variable multiple times. but in my case i need too.
i could just get the initial working directory and store that in a variable that never gets changed.

Failed to download

Describe the bug
Failed to download

  • MacOS

Terminal
% redvid -u "https://v.redd.it/xq3xuxbvf9bc1" -mxq

Connecting...
Scraping...
Downloading and Re-encoding...
Video:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1786, in open
return getattr(self, name)(url)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1995, in open_https
return self._open_generic_http(self._https_connection, url, data)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1944, in _open_generic_http
http_conn.request("GET", selector, headers=headers)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1285, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1331, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1280, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1040, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 980, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 501, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1041, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1310, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/bin/redvid", line 8, in
sys.exit(run())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/redvid/main.py", line 120, in run
reddit.download()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/redvid/redvid.py", line 263, in download
self.get_and_mux()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/redvid/redvid.py", line 134, in get_and_mux
self.get_video()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/redvid/redvid.py", line 122, in get_video
self.pgbar(self.log, self.video, self.temp + self.__unique_id + 'video.mp4', '>> Video:')
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/redvid/requestmaker.py", line 224, in pgbar
opener.retrieve(url, filename=output_path, reporthook=reporthook)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1820, in retrieve
fp = self.open(url, data)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1792, in open
raise OSError('socket error', msg).with_traceback(sys.exc_info()[2])
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1786, in open
return getattr(self, name)(url)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1995, in open_https
return self._open_generic_http(self._https_connection, url, data)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1944, in _open_generic_http
http_conn.request("GET", selector, headers=headers)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1285, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1331, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1280, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1040, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 980, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 501, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1041, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1310, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

Progress bar not easily readable

Progress bar is not easy to read in the Python shell, needs to be printed on a new line each time. See attached image. I can perhaps attempt to fix, but still fairly bad at programming.

image

[WinError 2] The system cannot find the file specified: 'av.mp4'

Hi, I don't understand why I'm facing this issue while trying to download a video, i get this exception

[WinError 2] The system cannot find the file specified: 'av.mp4'

this is my code:

reddit = Downloader()
reddit.max = True
reddit.url = str(link)
reddit.download()

Any help would be appreciated, thank you so much.

Feature Request: Allow video_url to be from v.redd.it

Right now this only works with the full reddit permalink: https://reddit.com/r/subreddit/post-title-goes here

It would be useful to be able to use this with the "https://v.redd.it" URL, for example: https://v.redd.it/c8oic7ppc2751

I've got it working with the following workaround:

submissions = reddit.user.me().submissions.new(limit=None)
  for submission in submissions:
    if "v.redd" in submission.url:
      video_url = "https://reddit.com" + submission.permalink   #permalink comes in "/r/subreddit/post-title" format, so this string combination creates the requisite URL
     redvid.Download(video_url)

feature request: allow user to choose where the file gets saved to.

Hello,

I've been playing with this all day and I gotta say, its pretty great. I know its new, and I was hoping you might add functionality to choose a location where you save the video, instead of the current directory. I know that in a python script, I could "os.chdir(path)", but that seems to have trouble, and I get "[Errno 18] Invalid cross device link", even though it actually works correctly - (sometimes when it merges audio and video, it doesn't delete the .m4a and the video.mp4 file, even though the finish product works well).

Also, I noted that your TODO says you want to add gif functionality - just wanted to let you know that I tested this with gifs and it already works (but saves it as .mp4 format - that works fine for my purposes, but I understand if people want .gif natively).

Thanks,

Ben

Feature request for silent downloads

Hey Khaled,

Thanks for the making this. Do you think you could add an option for disabling the progress messages so we can clean logs? Like a silent flag in most command line applications

Also I have a use case where I'd like to only mirror a reddit video if it's not too big e.g if the video is over 20MB don't download it. Is this something that can be implemented?

[WinError 5] Access is denied: 'temp'

reddit = Downloader()
reddit.auto_max = True
reddit.path = r'C:\Users\Public\Desktop'
# redvid will find the quality with the size
# that does not exceed max_s (3 MB)
reddit.max_s = 15 * (1 << 20)
reddit.url = link
reddit.download()

Error:

>> Connecting...
[WinError 5] Access is denied: 'temp'

I am trying to download video at my desktop but I am getting this error saying Access is denied.
May I know how would I resolve this, and how would I set custom name for my video file?

Video data

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.

Select custom quality without user intervention

I'm in a situation where I would like to select the highest quality while being under the defined size limit. I can set quality to be highest or lowest but I can't find a way to retrieve the list of qualities from UserSelect or select a custom quality.
TL;DR: I was wondering if there was a way to select the highest quality under a given size limit, or at least be able to select a quality without needing user intervention.

Audio is not getting added with the video :(

Describe the bug
when I try to download a video it doesn't comes with the audio

Does anyone else have the same problem
I used the code like this
reddit = Downloader()
reddit.path = path
reddit.max = True
reddit.url = url
reddit.download()

mpdParse does not get the highest resolution video

Describe the bug
When trying to download a video in max available quality, redvid downloads only the second best quality. This is because the mpdParse regex doesn't match the pattern for the highest available quality:

tags = r'<BaseURL>(DASH_)(?!vtt)(.*?)(\.mp4)?</BaseURL>'

For example, here the max available quality is 1080p (maxHeight="1080") but only the video in 720p is downloaded

MPD:

https://v.redd.it/rv112toa1l7d1
---
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" mediaPresentationDuration="PT53.366664886S" minBufferTime="PT4S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static">
  <Period duration="PT53.366664886S" id="0">
    <AdaptationSet contentType="video" id="0" maxHeight="1080" maxWidth="1920" par="16:9" sar="1:1" segmentAlignment="true" startWithSAP="1">
      <Representation bandwidth="263654" codecs="avc1.4d401e" frameRate="15360/512" height="220" id="1" mimeType="video/mp4" width="392">
        <BaseURL>DASH_220.mp4</BaseURL>
        <SegmentBase indexRange="883-1082" timescale="15360">
          <Initialization range="0-882" />
        </SegmentBase>
      </Representation>
      <Representation bandwidth="475682" codecs="avc1.4d401e" frameRate="15360/512" height="270" id="2" mimeType="video/mp4" width="480">
        <BaseURL>DASH_270.mp4</BaseURL>
        <SegmentBase indexRange="862-1061" timescale="15360">
          <Initialization range="0-861" />
        </SegmentBase>
      </Representation>
      <Representation bandwidth="844508" codecs="avc1.4d401e" frameRate="15360/512" height="360" id="3" mimeType="video/mp4" width="640">
        <BaseURL>DASH_360.mp4</BaseURL>
        <SegmentBase indexRange="863-1062" timescale="15360">
          <Initialization range="0-862" />
        </SegmentBase>
      </Representation>
      <Representation bandwidth="1295776" codecs="avc1.4d401f" frameRate="15360/512" height="480" id="4" mimeType="video/mp4" width="854">
        <BaseURL>DASH_480.mp4</BaseURL>
        <SegmentBase indexRange="883-1082" timescale="15360">
          <Initialization range="0-882" />
        </SegmentBase>
      </Representation>
      <Representation bandwidth="2478668" codecs="avc1.4d401f" frameRate="15360/512" height="720" id="5" mimeType="video/mp4" width="1280">
        <BaseURL>DASH_720.mp4</BaseURL>
        <SegmentBase indexRange="862-1061" timescale="15360">
          <Initialization range="0-861" />
        </SegmentBase>
      </Representation>
      </AdaptationSet>
    <AdaptationSet contentType="audio" id="1" segmentAlignment="true" startWithSAP="1">
      <Representation audioSamplingRate="48000" bandwidth="67854" codecs="mp4a.40.2" id="7" mimeType="audio/mp4">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
        <BaseURL>DASH_AUDIO_64.mp4</BaseURL>
        <SegmentBase indexRange="820-1019" timescale="48000">
          <Initialization range="0-819" />
        </SegmentBase>
      </Representation>
      <Representation audioSamplingRate="48000" bandwidth="133975" codecs="mp4a.40.2" id="8" mimeType="audio/mp4">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
        <BaseURL>DASH_AUDIO_128.mp4</BaseURL>
        <SegmentBase indexRange="820-1019" timescale="48000">
          <Initialization range="0-819" />
        </SegmentBase>
      </Representation>
    </AdaptationSet>
    </Period>
</MPD>

To Reproduce
Steps to reproduce the behavior:

  1. Scrape https://v.redd.it/rv112toa1l7d1 using redvid
if __name__ == "__main__":
    reddit = Downloader(max_q=True)
    reddit.url = 'https://v.redd.it/rv112toa1l7d1'
    reddit.download()
  1. Observe 720p video instead of 1080p video downloaded

Expected behavior
1080p video is downloaded

MissingSchema with valid url

Keep getting the error "No schema supplied" error when using valid url's (https://v.redd.it/identifier) yet it allways errors out.

Code i used was the video without audio example

Error log:

/usr/bin/python3.8 /home/archie/Downloads/python/downloader.py

Connecting...
Traceback (most recent call last):
File "/home/archie/Downloads/python/downloader.py", line 17, in
reddit.download()
File "/usr/local/lib/python3.8/dist-packages/redvid/redvid.py", line 230, in download
self.check()
File "/usr/local/lib/python3.8/dist-packages/redvid/redvid.py", line 160, in check
self.setup()
File "/usr/local/lib/python3.8/dist-packages/redvid/redvid.py", line 69, in setup
self.url = self.get(
File "/usr/local/lib/python3.8/dist-packages/redvid/requestmaker.py", line 208, in get
return requests.get(url, headers={'User-Agent': random.choice(self.USER_AGENTS)}, proxies=_proxies)
File "/usr/lib/python3/dist-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 519, in request
prep = self.prepare_request(req)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 452, in prepare_request
p.prepare(
File "/usr/lib/python3/dist-packages/requests/models.py", line 313, in prepare
self.prepare_url(url, params)
File "/usr/lib/python3/dist-packages/requests/models.py", line 387, in prepare_url
raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'v.redd.it/c8oic7ppc2751': No schema supplied. Perhaps you meant http://v.redd.it/c8oic7ppc2751?

Process finished with exit code 1
Might be an issue with my setup, not completely sure, thanks for any help given :)

When choosing PATH the video will not be saved in the choosen path unless it already exists.

Describe the bug
When selecting a path where the video will be downloaded to it saves it in the parent folder if the selected folder does not exist.

To Reproduce

reddit = Downloader(max_q = True) 
reddit.log = False
reddit.path = 'C:\\Users\\MyUser\\Desktop\\bot\\NonExistentFolder\\'
reddit.url = 'https://www.reddit.com/r/pythonforengineers/comments/hfmo98/what_kind_of_hawk_is_this/'
reddit.download()

Expected behavior
The propper way to implement the path functionality should be to create a folder in case it does not exist.

Desktop:

  • OS: Windows 10

I know this is not super important but your library is super useful and I thought this might help with it.
Also, is there a way to change the file name or get it's name once it has been downloaded?

Incorrect URL format - Redvid has suddenly stopped working for me

Describe the bug
Since a few days I'm getting a BaseException: Incorrect URL format error when trying to download media.

To Reproduce

from redvid import Downloader

reddit = Downloader(max_q=True)
reddit.url = 'https://v.redd.it/gwfmodtx1p3c1'
reddit.download()

Has anything changed on reddits side? I am using redvid==2.0.2

Download the videos of the top 10 posts from a subreddit

I was wondering how I could download the videos from the top 10 posts of a subreddit.

The program would go through the top posts of a subreddit, if there isn't a video it would skip the post, and if there is a video it would download it.

This is more fit to be put in a "Discussion" heading, but there isn't one, so I thought it'd be alright to put it here.

Some Submissions Have Inverted Quality Order

Hello, been dealing with this since last night. Took me a bit to figure out what's causing it but unfortunately I don't have a proposed solution at the moment.

Take for example, this submission. I'm not quite sure what could be making this video different aside from the format, but when attempting to download it without .min or .max enabled, I am given this.

This wouldn't be too much of a problem were it not to mess with how .min and .max choose their respective qualities -- trying to automate downloading these results in it throwing errors with my media player, as it'll usually just download the audio stream.

Unable to use Downloader

Describe the bug
When running downloader using python 3.7, Video download/encoding fails due to codec

To Reproduce

  1. Using the example script:
    from redvid import Downloader

reddit = Downloader(max_q=True)
reddit.url = 'https://v.redd.it/c8oic7ppc2751'
reddit.download()

  1. run the script:
    python downloader.py

  2. Get the following error:

Connecting...
Scraping...
Downloading and Re-encoding...
Video:

Traceback (most recent call last): ] [0.02/1.09 MB]
File "downloader.py", line 5, in
reddit.download()
File "E:\Program Files\Python37\lib\site-packages\redvid\redvid.py", line 249, in download
self.get_and_mux()
File "E:\Program Files\Python37\lib\site-packages\redvid\redvid.py", line 128, in get_and_mux
self.get_video()
File "E:\Program Files\Python37\lib\site-packages\redvid\redvid.py", line 116, in get_video
self.pgbar(self.log, self.video, 'video.mp4', '>> Video:')
File "E:\Program Files\Python37\lib\site-packages\redvid\requestmaker.py", line 224, in pgbar
opener.retrieve(url, filename=output_path, reporthook=reporthook)
File "E:\Program Files\Python37\lib\urllib\request.py", line 1824, in retrieve
reporthook(blocknum, bs, size)
File "E:\Program Files\Python37\lib\site-packages\redvid\requestmaker.py", line 200, in reporthook
lprint(logg, '\r>>>>', pgbar, end='\r')
File "E:\Program Files\Python37\lib\site-packages\redvid\tools.py", line 9, in lprint
print(*args, **kwargs)
File "E:\Program Files\Python37\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2588' in position 1: character maps to

  1. temp folder contains mp4 with ~1 frame of the video recorded

Expected behavior
The video is downloaded as expected

Desktop (please complete the following information):

  • OS: Windows 7
  • Command line python
  • Python Version 3.7.3

Additional context
Havent been able to get the script working

Output File Named Incorrectly

Description
After file is scraped from reddit, the file is moved to the output file. It seems that the file isn't named properly, so windows raises a winerror stating that the file could not be found. The error can be fixed by changing the name of the os.rename function in the get_and_mux fuction from "av.mp4" to "video.mp4". I will make a pull request to fix the bug.

Desktop:

  • OS: Windows 11

Changing the video's name

To easily change the name of the newly downloaded video, you can use the cmd command "os.rename".

import os
from redvid import Downloader
 
reddit = Downloader()
reddit.url = 'https://v.redd.it/c8oic7ppc2751'
reddit.download()
 
# Now You Can Rename
new_name = 'A hawk.mp4'
os.rename(reddit.file_name, new_name)

(Thanks to elmoiv for the answer)

[CRITICAL] Reddit changed it's video hosting architecture, can't download video and audio anymore

Describe the bug
Reddit changed it's video hosting architecture, can't download video and audio anymore, if you set max_q to true it will download just audio as an mp4, if it's not set to anything it will only let you download either a video or an audio file

https://www.reddit.com/r/redditdev/comments/15cdln3/reddit_changed_what_url_audio_from_a_video_is/

To Reproduce
Just download any video posted recently

Expected behavior
It should detect audio and video qualities separately

I have patched it but very crudely so I didn't make a pull request, Best way to fix it would be by modifying mpdParse I reckon

here is my temporary fix:

def scrape(self):
        """
        Gets direct video and audio (if exists) urls
        """
        self.UNQ = getUNQ(self.page)

        if not self.UNQ:
            Clean(self.temp)
            raise BaseException('No video in this post')
        
        self.r_url = 'https://v.redd.it/' + self.UNQ + '/'

        # Getting Qualities and audio (if exists) from mpd file
        mpd = self.get(
                        self.r_url + 'DASHPlaylist.mpd',
                        _proxies=self.proxies
                        )
        # v1.0.8: Fix new Reddit mechanism
        #VQS, AQS = mpdParse(mpd.text)

        #new fix???
        QS,dontknowwhattodoherelol = mpdParse(mpd.text)
        AQS = [Quality for Quality in QS if 'AUDIO' in Quality[1]]
        VQS = [Quality for Quality in QS if 'AUDIO' not in Quality[1]]
        
        if [VQS, AQS] == [0, 0]:
            raise BaseException('Qualities not found!')

        self.videos = VQS
        
        # Check for Audio
        if AQS:
            self.audio = self.r_url + j(AQS[-1])  #depends on chosen quality, -1 selects the last one (the best)
def get_and_mux(self):
        """
        Video or muxed video with audio if exists
        """
        self.get_video()

        # v1.0.5: Convert muted videos to be shareable
        if self.audio:
            self.get_audio()
            os.system(
                    'ffmpeg -hide_banner -loglevel panic -y -i "{0}video.mp4"'
                    ' -i "{0}audio.mp4" -vcodec copy -acodec copy "{0}av.mp4"'.format(
                        self.temp
                    )
                )                     #changed audio to mp4 not m4a
        else:
            os.system(
                    'ffmpeg -hide_banner -loglevel panic -y -i "{0}video.mp4"'
                    ' -vcodec copy "{0}av.mp4"'.format(
                        self.temp
                    )
                )

        # Moving video file without using shutil
        os.rename(self.temp + 'av.mp4', self.file_name)

        # Clean Temp folder
        Clean(self.temp)

No such file or directory: 'av.mp4'

Describe the bug
I'm getting this error during trying to download any video.

Screenshots
image

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Python Version: 3.8.2

Returning the path and file name of the downloaded video?

Hello! Been using this library for a few days, it's great. I think in 1.05, the download() function would return the entire path to the downloaded file, right? I updated and had to change some stuff around. It'd be really convenient, just a small suggestion.

Thank you,
Wade

Random audio track given to videos with no audio track

Describe the bug
A random audio track will be downloaded and applied to silent videos.
To Reproduce
Steps to reproduce the behavior:
My code is looped through multiple times, I think this may be an issue with the downloader not clearing the cached audio on download/newurl
Expected behavior
A silent video to be downloaded.

Desktop (please complete the following information):

  • OS: Manjaro

Unable to merge the video and audio file in the Temp folder

Hi, This is my first issue report ever. So apologies for any mistakes I make.

I am getting an 'file not found' error when I try to download any video using redvid.

example error I get = ' FileNotFoundError: [WinError 2] The system cannot find the file specified: 'E:\$github folder\Dizzibot\images\temp\av.mp4' -> 'E:\$github folder\Dizzibot\images\a4gyy9ujm7k71-DASH_360.mp4' '

This error is something which i am getting from the last few weeks. It used to work properly before.

And also I am getting an error saying 'ffmpeg is not recognised as internal or external command' on top of this.

If you need anything else, glad to help.

Screenshot 2021-08-29 194036

BaseException: Incorrect URL format

Can't download any videos on my server, always receive the same error: "BaseException: Incorrect URL format"

root@ubuntu-s-1vcpu-2gb-amd-sfo3-01:/home/username/test/smart_reposter# redvid -u "https://v.redd.it/c8oic7ppc2751" -mxq

Connecting...
Traceback (most recent call last):
File "/usr/local/bin/redvid", line 8, in
sys.exit(run())
File "/usr/local/lib/python3.8/dist-packages/redvid/main.py", line 120, in run
reddit.download()
File "/usr/local/lib/python3.8/dist-packages/redvid/redvid.py", line 239, in download
self.check()
File "/usr/local/lib/python3.8/dist-packages/redvid/redvid.py", line 165, in check
self.setup()
File "/usr/local/lib/python3.8/dist-packages/redvid/redvid.py", line 87, in setup
raise BaseException('Incorrect URL format')
BaseException: Incorrect URL format

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.