Coder Social home page Coder Social logo

simondaninja / youtube_rss Goto Github PK

View Code? Open in Web Editor NEW
52.0 3.0 3.0 244 KB

A YouTube-client for managing subscriptions and watching videos anonymously over Tor without a Google account.

License: GNU General Public License v3.0

Python 100.00%
tor anonymity subscription youtube youtube-rss rss thumbnails

youtube_rss's Introduction

YouTube_RSS

YouTube_RSS is a simple YouTube client I've made for fun. The goal is to have a simple user interface for those who want to preserve their privacy when using YouTube, but who still want to be able to keep track of their favourite channels, etc.

YouTube_RSS manages subscriptions to channels using RSS, rather than YouTube's internal subscription system that requires a privacy violating Google account.

It also (optionally) uses Tor to hide the IP address of the user.

Dependencies

YouTube_RSS is developed and tested on Ubuntu Linux. It will probably work just fine in similar Unix-like operating systems, but probably not on Windows (at least not without a little bit of pain).

The following python modules are used and may need to be installed, e.g. using pip:

aiohttp
aiohttp-socks
feedparser
urllib3

The program also assumes that mpv is installed in the environment. In, for example, Ubuntu, this can be accomplished by running sudo apt-get install mpv. youtube-dl also needs to be installed (I use the latest version on their official website, and at the time of this writing, the version in the Ubuntu rebository seems too old to work the way this project uses it).

For using Tor, YouTube_RSS assumes that Tor is installed and currently running on port 9050 (which is the default for the Tor daemon anyway). It also requires that torsocks is installed.

Disclaimer

Note that while I am enthusiastic about privacy and security, I am not a professional, and may have missed something important. However, the surface to protect should be relatively small, and I've taken care to get rid of DNS-leaks, etc. as well as I can. If you are more knowledgable than I, then I would appreciate input on how to make YouTube_RSS more privacy preserving and secure.

Manual

Most of the way the application works is self-explanatory; I won't tell you that to search for a video, you enter the "search for video" option (although I guess I just did), but rather focus on the things not immediately obvious when opening the program.

Key binds

The keybindings are designed so that the user can do almost everything necessary by just using the arrow keys (except, of course, when writing search queries), or by using the hjkl keys for vi users.

When in a menu, the user can press KEY_UP or k to move to the previous menu item.

When in a menu, the user can press KEY_DOWN or j to move to the next menu item.

When in a menu, the user can press g (lower case) to go to the first menu item.

When in a menu, the user can press G (upper case) to go to the last menu item.

When in a menu, the user can type a number and then press either Enter or l or KEY_RIGHT to jump to the item indicated by the number typed by the user.

When in a menu, the user can press ENTER, l or KEY_RIGHT to select the highlighted item, if no number has been typed since last jump.

When in a menu, the user can press q, <Ctrl>-C, h or KEY_LEFT to go back to the previous menu.

When browsing subscriptions, in the menu where channels are displayed as menu items, the user can press a to toggle all entries of the currently highlighted channel as seen or unseen

When browsing subscriptions, in the menu where videos from a particular channel are displayed as menu items, the user can press a to toggle the highlighted entry as seen or unseen

Thumbnails

YouTube_RSS used to support thumbnails, using ueberzug, but no longer does, since that project has sadly been discontinued.

If you used YouTube_RSS with thumbnails in the past, you need to manually delete thumbnail files, which are stored under ~/.youtube_rss/thumbnails.

youtube_rss's People

Contributors

simondaninja 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

Watchers

 avatar  avatar  avatar

youtube_rss's Issues

Implement logging

To more easily locate the sources of bugs, I should implement some form of logging. I've done this on the fly sometimes, but it should be done in a more formalized fashion.

Error with creating/opening database file

On Arch Linux, running commit 3166c53, I get the following error when trying to run youtube_rss.py:

Traceback (most recent call last):
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 1281, in <module>
    database = doWaitScreen('', parseDatabaseFile, DATABASE_PATH)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 410, in doWaitScreen
    return curses.wrapper(doWaitScreenNcurses, message, waitFunction, *args, **kwargs)
  File "/usr/lib/python3.9/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 419, in doWaitScreenNcurses
    return waitFunction(*args, **kwargs)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 851, in parseDatabaseFile
    with open(filename, 'r') as filePointer:
FileNotFoundError: [Errno 2] No such file or directory: '/home/matteas/.youtube_rss/database'

A quick workaround is to simply run touch ~/.youtube_rss/database, which allows the script to run, but doesn't ultimately solve the issue. When trying to do anything with subscriptions, there are then inevitably errors because the program is trying to read from an empty file. Such as:

Traceback (most recent call last):
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 1284, in <module>
    doStartupMenu(runtimeConstants)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 1151, in doStartupMenu
    doMethodMenu("Do you want to use tor?", menuOptions, showItemNumber=False)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 1223, in doMethodMenu
    result = methodMenuDecision.executeDecision()
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 326, in executeDecision
    return self.function(*self.args, **self.kwargs)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 1209, in doMainMenu
    doMethodMenu("What do you want to do?", menuOptions)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 1223, in doMethodMenu
    result = methodMenuDecision.executeDecision()
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 326, in executeDecision
    return self.function(*self.args, **self.kwargs)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 981, in doInteractiveChannelSubscribe
    doMethodMenu(f"search results for '{query}', choose which " + \
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 1223, in doMethodMenu
    result = methodMenuDecision.executeDecision()
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 326, in executeDecision
    return self.function(*self.args, **self.kwargs)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 994, in doChannelSubscribe
    database = doWaitScreen('', parseDatabaseFile, DATABASE_PATH)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 410, in doWaitScreen
    return curses.wrapper(doWaitScreenNcurses, message, waitFunction, *args, **kwargs)
  File "/usr/lib/python3.9/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 419, in doWaitScreenNcurses
    return waitFunction(*args, **kwargs)
  File "/home/matteas/youtube_rss/./youtube_rss.py", line 852, in parseDatabaseFile
    return json.load(filePointer, cls = DatabaseDecoder)
  File "/usr/lib/python3.9/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.9/json/__init__.py", line 359, in loads
    return cls(**kw).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 1 column 1 (char 0)

I tried debugging it myself, but I don't know anything about waitFunction and the rest of the code makes it a little unclear exactly what the database file is supposed to look like. There's, uhh, no info in the README either, so I'm a little stuck. Figured I'd make an issue here instead of spending more time reverse engineering the code.

Any help is appreciated.

YouTube's new consent page breaks channel search function

When getting search query html, you get redirected to a new consent page. Suggested solution is to analyze the forms on the page, and either accept tracking (since they will be discarded right away regardless, and this will probably be an easier solution), or to customize settings and disagree (which will take some more time but probably be better in the long run). Cookies are probably not an issue, since they can be instantly discarded. However, geolocation etc. is also sent in the form and might be an issue for users who are not using Tor.

Error when refreshing subscriptions

I'm on MacOS 10.15.7
Upon refreshing subscriptions, very briefly, I get an error message:
I can't see the whole thing, but here is what it partially says:

refreshing subscriptions ... Process Process-2:
Traceback (most recent call last):
File "/usr/local/Cell
hona3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 315. in bootstrap self.run( )
Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 108, in run Fite /usr/Local/Cellar/pythonas. 9/3.9.5/Fram
self._target(*self._args, **self._wargs)
77 in refreshSubsriptionsByChannelss File "/Users/#####/youtube_rss/youtube_rss.py"
if USE THUMBNAILS:
NameError: name 'USE THUMBNAILS' is not defined

Refactoring

This program is starting to outgrow the single-file model. It worked really well up until I started doing threading, but now it is in need of reorganization.

On the fly, I improvised the following strategy just to quickly get some runtime stability, which is currently implemented. However, it is in need of improvement, and explicitly enforced formalization (only keeping it in my head leads to bugs):

  • Threading is done in exactly one child process, which has many threads. If something goes wrong with a thread, the child process is killed.
  • database is read/written from/to file every time that it is needed rather than stored in memory. However it is only done when exactly one process is non-idle, and has exactly one thread - when used in threading, it is passed on to these in memory, and thread safety is ensured by locking it when modifying it.
  • UI-stuff is never done in the threaded process

I suggest that these be formalized in some way. At the very least, all functions that start a threaded process should be kept in a separate file, so that it becomes extra clear when a threaded process is started, and what takes place in the threaded process vs. the non-threaded process.

Also, right now there can be way to many threads at a time. I should implement a thread manager class, to do thread book-keeping. It should be relatively simple; make sure that a maximum of X threads are active at a time, and no fewer than that if needed. It should basically just be used as an interface to the thread class.

Import: not found

I've installed all dependencies yet I get errors:

I'm on NetBSD so I'm guessing that perhaps the paths are a bit mixed up?

$ sh youtube_rss.py
from: can't read /var/mail/html.parser: No such file or directory
youtube_rss.py: import: not found
youtube_rss.py: import: not found
youtube_rss.py: import: not found
youtube_rss.py: import: not found
from: can't read /var/mail/json: No such file or directory
from: can't read /var/mail/json: No such file or directory
youtube_rss.py: import: not found
youtube_rss.py: import: not found
youtube_rss.py: try:: not found
from: can't read /var/mail/tor_requests.tor_requests: No such file or directory
from: can't read /var/mail/tor_requests.tor_requests: No such file or directory
youtube_rss.py: except:: not found
youtube_rss.py: 36: Syntax error: Word "�you proba..." unexpected (expecting ")")
$ ./youtube_rss.py
Traceback (most recent call last):
  File "./youtube_rss.py", line 24, in <module>
    import requests as req
ModuleNotFoundError: No module named 'requests'

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.