gedisony / plugin.video.reddit_viewer

Kodi addon for reddit.com
GNU General Public License v2.0
22 stars 7 forks source link

Options in the left sidepanel to show top videos for month/year and similar options to alter the video results #9

Open mYnDstrEAm opened 2 years ago

mYnDstrEAm commented 2 years ago

On reddit you can show videos of a subreddit top rated during the last week/month/year and have other options to change which videos are displayed. Currently, the addon can only show the one view of videos currently trending on the subreddit, which limits its useful a lot.

It probably wouldn't be very difficult to change this as you can change the results with some url parameters / options (like https://www.reddit.com/r/videos/top/?t=week). It may also be useful to show the results as they are currently shown but for yesterday when turning to the next results page in Kodi but that may not be as simple / may not be supported from how the data is retrieved.

gedisony commented 2 years ago

I debated on putting this as an addon setting but eventually opted to put it where you setup your favorite subreddits.

e.g. Instead of just "mealtimevideos" (which will translate to https://www.reddit.com/r/mealtimevideos) you create a shortcut mealtimevideos/top/?t=week this will translate to https://www.reddit.com/r/mealtimevideos/top/?t=week

something like this will also work: gametrailers+tvtrailers+trailers/top/?t=month https://www.reddit.com/r/gametrailers+tvtrailers+trailers/top/?t=month

The default list of subreddits (when you initially install the addon) have some examples but not as complicated as having the t=week options

as you predicted, a 'yesterday' option will not work because reddit does not support it.

mYnDstrEAm commented 2 years ago

Didn't know that. I'd propose adding the top of week for /r/videos and maybe a few other subreddits into the defaults and adding some info about how to add new subreddits to the description of Add Subreddit on the left (that the format should be like mealtimevideos/top/?t=week).

Furthermore, when I try to add mealtimevideos/top/?t=week I get an Reddit Viewer Error with this error in the logs when I click on it:

 INFO <general>: initializing python engine.
 INFO <general>: CPythonInvoker(7, /home/username/.kodi/addons/plugin.video.reddit_viewer/default.py): script successfully run
 INFO <general>: Python interpreter stopped
 INFO <general>: initializing python engine.
ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                  - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                 Error Type: <class 'json.decoder.JSONDecodeError'>
                 Error Contents: Expecting value: line 2 column 5 (char 5)
                 Traceback (most recent call last):
                   File "/home/username/.kodi/addons/plugin.video.reddit_viewer/default.py", line 170, in <module>
                     plugin_modes[mode](url,name,type_)
                   File "/home/username/.kodi/addons/plugin.video.reddit_viewer/resources/lib/main_listing.py", line 170, in listSubReddit
                     content = json.loads(content)
                   File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
                     return _default_decoder.decode(s)
                   File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
                     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
                   File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
                     raise JSONDecodeError("Expecting value", s, err.value) from None
                 json.decoder.JSONDecodeError: Expecting value: line 2 column 5 (char 5)
                 -->End of Python script error report<--

 INFO <general>: Python interpreter stopped
ERROR <general>: GetDirectory - Error getting plugin://plugin.video.reddit_viewer/?mode=listSubReddit&type=mealtimevideos%2ftop%2f%3ft%3dweek&url=https%3a%2f%2fwww.reddit.com%2fr%2fmealtimevideos%2ftop%2f%3ft%3dweek%2f.json%3f%26limit%3d50
ERROR <general>: CGUIMediaWindow::GetDirectory(plugin://plugin.video.reddit_viewer/?mode=listSubReddit&type=mealtimevideos%2ftop%2f%3ft%3dweek&url=https%3a%2f%2fwww.reddit.com%2fr%2fmealtimevideos%2ftop%2f%3ft%3dweek%2f.json%3f%26limit%3d50) failed
 INFO <general>: initializing python engine.
 INFO <general>: CPythonInvoker(9, /home/username/.kodi/addons/plugin.video.reddit_viewer/default.py): script successfully run
 INFO <general>: Python interpreter stopped

However, all the other default subreddits work and adding the mealtime/top subreddit worked too and has the correct description on the left when I hover on it.

Just as a note but maybe a yesterday-function could work by using some other API than the reddit API itself and maybe it works (now or in the future) by using reddits search function.