Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonneutert/reddit-api-image-getter
Gets images from a subreddit and optionally saves them.
https://github.com/simonneutert/reddit-api-image-getter
axios javascript node node-js node-module nodejs npm-package reddit subreddit xhr
Last synced: about 2 months ago
JSON representation
Gets images from a subreddit and optionally saves them.
- Host: GitHub
- URL: https://github.com/simonneutert/reddit-api-image-getter
- Owner: simonneutert
- License: mit
- Created: 2020-01-12T11:53:13.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-09-24T09:01:30.000Z (4 months ago)
- Last Synced: 2024-11-15T20:41:34.043Z (about 2 months ago)
- Topics: axios, javascript, node, node-js, node-module, nodejs, npm-package, reddit, subreddit, xhr
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/reddit-api-image-getter
- Size: 21.5 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Reddit API Image Getter
## Install
`npm i reddit-api-image-getter --save`
## Open Source
Check out the source code on GitHub and dig in a little for yourself.
## Example
~~~javascript
// example
const path = require('path')
redditApiImageGetter = require('reddit-api-image-getter')getter = new redditApiImageGetter()
// `getHotImagesOfSubReddit('subreddit')`
// returns a Promise, that, when successful returns
// an Array containing RedditImageEntry object instances.
//
// Each RedditImageEntry object is then passed to
// `saveRedditImageEntryToDisk(imageEntry, path)`
// to be saved to disk.
//
// See what each RedditImageEntry does in
// lib/classes/RedditImageEntry.js and lib/classes/RedditEntry.js
//
// get the top images of a subreddit: using
// getTopImagesOfSubReddit(subreddit = 'ProgrammerHumor')
//
getter.getHotImagesOfSubReddit('ProgrammerHumor').then(function (result) {
for (imageEntry of result) {
const targetDirectory = path.resolve(__dirname, 'images', 'hot');
getter.saveRedditImageEntryToDisk(imageEntry, targetDirectory);
}
}).catch(function (error) {
console.log(error)
})getter.getTopImagesOfSubReddit('ProgrammerHumor').then(function (result) {
for (imageEntry of result) {
// do begin with a starting '/' if you need to:
// https://nodejs.org/api/path.html#path_path_resolve_paths
const targetDirectory = path.resolve(__dirname, 'images', 'top');
getter.saveRedditImageEntryToDisk(imageEntry, targetDirectory);
}
}).catch(function (error) {
console.log(error)
})
~~~## Example with Telegram Bot
https://www.simon-neutert.de/2020/telegraf-bot-nodejs/
## Inspiration
go crazy, send the pictures to your telegram via a bot (using a [bot](https://core.telegram.org/bots/samples#node-js)) and make your day a happy day :tada: