Skip to content

Commit fb6bea0

Browse files
committed
Imgur Support
1 parent 8075231 commit fb6bea0

3 files changed

Lines changed: 32 additions & 5 deletions

File tree

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
A very easy to use Reddit Media Downloader. The library can also be used to download pictures and even picture galleries all just with a reddit post link. You can access Reddit API methods without having your own bot with classes such as ```DownloadBySubreddit``` more on that below.
4545

46-
<b>NOTE: </b> this package only downloads media from posts with images/video directly uploaded to reddit and not from sources like imgur or youtube / vimeo which are posted to Reddit.
46+
<b>NOTE: </b> As of RedDownloader 4 only Youtube and Imgur Single Image Posts are supported
4747

4848
<h1> Installation </h1>
4949
To Install the package:
@@ -250,6 +250,15 @@ audio = RedDownloader.GetPostAudio(url)
250250

251251
To change the file download destination you can set the ```destination``` argument to the path you want to download the file to. By default it downloads the file in the current working directory. To change to output file name you can set the ```output``` argument to the name of the file you want to download the audio to. By default it downloads the file with the name ```Audio.mp3```.
252252

253+
<h1>New Features in RedDownloader 4.0:</h1>
254+
255+
<h2> Youtube and Imgur Support</h2>
256+
257+
Starting RedDownloader 4 you can download reddit posts which link to a youtube video and imgur single files.
258+
<b>NOTE:</b> Imgur Album links are not yet supported
259+
260+
Any Version previous to RedDownloader 4 would yield a ```Post Not Recoganized Error```
261+
253262

254263
## Star History
255264

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="RedDownloader",
8-
version="3.3.0",
8+
version="4.0",
99
author="Arnav Bajaj",
1010
author_email="arnavbajaj9@gmail.com",
1111
description="A package to download Reddit hosted videos easily and efficiently.",

src/RedDownloader/RedDownloader.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'''
2-
This is the main source file for RedDownloader Version 3.3.0 with it's primary
2+
This is the main source file for RedDownloader Version 4.0 with it's primary
33
usage being downloading Reddit Posts i.e Image Posts , Videos , Gifs , Gallery
4-
Posts.
4+
Posts with additional support for Youtube links and Imgur Links.
55
'''
66

77
# Internal Imports
@@ -147,6 +147,21 @@ def __init__(
147147
except Exception as e:
148148
print("Connection Error")
149149
print(e)
150+
151+
elif "i.imgur.com" in self.postLink:
152+
print("Detected Post Type: Imgur Image")
153+
self.mediaType = "imgur"
154+
imageData = requests.get(self.postLink).content
155+
file = open(f'{self.output}' + '.jpeg', 'wb')
156+
file.write(imageData)
157+
file.close()
158+
print("Sucessfully Downloaded Image: " + f"{self.output}")
159+
if self.destination is not None:
160+
shutil.move(f"{self.output}.jpeg", self.destination)
161+
162+
elif "imgur.com" in self.postLink:
163+
print("Detected Post Type: Imgur Album")
164+
print("Support for imgur album posts has not yet been added")
150165

151166
else:
152167
print("Error: Could Not Recoganize Post Type")
@@ -1079,4 +1094,7 @@ def __init__(self, url, destination=None, output=None):
10791094
#DownloadBySubreddit("memes", 5, output="Subreddit API")
10801095

10811096
## Test For Youtube Links
1082-
##Download("https://www.reddit.com/r/videos/comments/xi89wf/this_guy_made_a_1hz_cpu_in_minecraft_to_run/", output="videoTest")
1097+
#Download("https://www.reddit.com/r/videos/comments/xi89wf/this_guy_made_a_1hz_cpu_in_minecraft_to_run/", output="videoTest")
1098+
1099+
## Test For Imgur Posts
1100+
#Download("https://www.reddit.com/r/pics/comments/xbzjbv/my_grandparents_100_yearolddresser_prerestoration/",destination="D:/Python")

0 commit comments

Comments
 (0)