Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1-Sisyphe/reddit-hot-recorder
Records the activity (comments and karma) on the hot page of a Reddit sub and prepare an animated data visualisation.
https://github.com/1-Sisyphe/reddit-hot-recorder
data-visualization matplotlib plot python reddit
Last synced: 3 months ago
JSON representation
Records the activity (comments and karma) on the hot page of a Reddit sub and prepare an animated data visualisation.
- Host: GitHub
- URL: https://github.com/1-Sisyphe/reddit-hot-recorder
- Owner: 1-Sisyphe
- License: mit
- Created: 2017-11-11T12:26:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-18T20:54:18.000Z (about 7 years ago)
- Last Synced: 2024-08-01T22:49:12.286Z (6 months ago)
- Topics: data-visualization, matplotlib, plot, python, reddit
- Language: Python
- Homepage:
- Size: 1.93 MB
- Stars: 92
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# reddit-hot-recorder
### What is it?
- My first published python project :)
- A script that collects metadata from a Reddit's subreddit hot section, at regular intervals, and turns it into a serie of charts, to be animated.Here is an extract of a recording of r/all:
![r/all example](https://i.imgur.com/OGnCV0W.gif)### How does it work?
- The hotcollect module takes care of collecting the data and can save it into a json.
- The hotplot module uses the collected data to generate a serie of charts.
- The final step requires a software to turn the serie of charts (.png files) into a movie or a .gif.##### required:
- matplotlib
- numpy
- [PRAW](https://praw.readthedocs.io/en/latest/)### Examples:
```python
from hotcollect import collect_data
from hotplot import plot_collec
data_collec = collect_data(sub='france',maxposts=10,interval_sec=30,
duration_min=5,feedback=True,savefile='france.json')
plot_collec(data_collec)
```
- This script will watch the top 10 posts of r/france during 5 minutes, every 30 seconds.
*note: You should not go below `interval_sec=10` as it takes a couple of seconds for the API to collect the data.*
- It will save the collected data in france.json.
- It will print the following feedback:
```shell
1/10 snapshot recorded on Nov 16 2017 11:37:37
2/10 snapshot recorded on Nov 16 2017 11:38:09
```
- `plot_collec(data_collec)` will generate 10 .png to be turned into a .mp4.
On linux, I use ffmepg to turns the serie of .png into a .mp4, as follow:
```shell
ffmpeg -start_number 1 -framerate 24 -i %04d.png output.mp4
```If your local time doesn't match the local time of your viewers, you can correct the timestamp of your collected data by using `offset_timestamp(data_collec, delta_hours)`.
For example, if I live in Europe and want to plot for american viewers (-7 hours compared to my local time):
```python
from hotcollect import collect_data, offset_timestamp
from hotplot import plot_collec
data_collec = collect_data(sub='all',maxposts=10,interval_sec=30,
duration_min=5,feedback=False)
for data in data_collec:
data = offset_timestamp(data, -7)
plot_collec(data_collec)
```### And finally:
- feel free to comment my code, declare issues, propose changes, etc.
It was a learning exercise for me, both on Python and on using GitHub.
- it's under MIT licence which mean that you can do whatever you want with it, if I understood correctly.
Don't do evil though, if ever you find a way to do evil things with it...