flypig.co.uk

List items

Items from the current list are shown below.

Newpipe

10 Mar 2025 : Day 1 #
Today we're moving on from yesterday's preamble to start work proper on getting NewPipe running on Sailfish OS.

Let's start by asking "What is NewPipe?" If you've used it, it'll need no explanation, for while it's a complex application both under-the-hood and from a user-interface perspective, its purpose is pretty straightforward.

NewPipe is a YouTube client. Except it's not exactly. It's also a SoundCloud client. And a media.ccc.de client. And a Bandcamp client. And a PeerTube client. Although I don't think it's actually a PeerTube client, more a client for accessing Framatube, which is a PeerTube instance.

The point is it allows access to various platforms for streaming and downloading audio and video. The backend, incidentally, allows plugins to be added for all sorts of sites, building on those I listed above. But as with the NewPipe app for Android, I'll be focusing on the five core services, starting with YouTube.

As Henry Hiles (QuadRadical) pointed out yesterday, there are other YouTube clients already available, including the rather nice Gtk4-based Pipeline app which is designed for use on Linux and even already known to work nicely on mobile Linux.

Until QuadRadical pointed it out I wasn't familiar with Pipeline, which is the main reason I chose NewPipe over it. But Pipeline is also quite different. It's written in Rust for a start, although that's absolutely not a reason to discount it. It's true that Rust isn't a language that lives comfortably on Sailfish OS, but there are examples of excellent apps for Sailfish OS written in Rust (vide Whisperfish) and with NewPipe being written in Java, it's in no better position to work on Sailfish OS. I'd say that Sailfish OS's support for Java is even poorer than its support for Rust.

But for full functionality Pipeline also relies on an external download utility, such as yt-dlp. That makes it less suitable for our purposes.

So Pipeline is also interesting and hopefully I'll get the chance to return to it. But since I'm already on this NewPipe track, I don't think Pipeline offers a strong enough reason to be diverted.

Let's look at the NewPipe Android app in more detail. Here are a few screenshots from the app, running under Android App Support on my Sailfish OS phone.
 
The four main tabs of the NewPipe Android app: Trending, What's New, Subscriptions and Bookmarked Playlists.


These screenshots show the four main tabs that are presented to the user when they open the app. These tabs are labelled Trending, What's New, Subscriptions and Bookmarked Playlists.

The Trending tab shows a list of audio tracks or videos that the service wants to show you for whatever reason. Presumably intended to represent media that's either popular or looks like it might become popular. But in practice I'm not sure what the algorithm is that's being used in the background.

Personally I have my YouTube history disabled, which means that when I visit the site on the Web I'm just presented with an empty page. But I know others like to be given suggestions for what to watch, in which case this tab will be a useful addition.

It's worth noting that this tab changes its name depending on which service is being used, but they're all variations on a theme: Trending, New and hot, Recent and Featured.

The What's New tab shows a chronological list of items for channels the user has explicitly subscribed to. When you visit a channel there's an overt Subscribe button you can select to subscribe to the channel's feed. The subscription is handled entirely locally — the fact is never transmitted to YouTube — and just means that the app will periodically check for new media released to the channel's feed. By default this is every five minutes, but this can be adjusted in the settings.

Subscriptions are much more useful for someone like me who's looking for a curated list of videos. And it all works nicely. Pulling the list down will trigger an update outside of the usual cadence.

Next is the Subscriptions tab. As you might imagine this shows all of the feeds that you've subscribed to. Just the feeds, not the content in the feeds. But you can of course just select one of them to drill down deeper and see the videos that have been released on the channel.

Finally we have the Bookmarked Playlists tab. I suppose technically the difference between a channel and a playlist is that anyone can create a playlist, whereas a channel feed is managed only by the channel owner. When you open a video you have the option to add it to one of your own playlists, or you can pull one of the playlists created by some other YouTube user. Either way they'll appear on this tab.

If you look carefully at the screenshots you'll also notice there's a little magnifying glass at the top right of the screen. Selecting this brings up a new page allowing you to search the entire service based on the text you enter. This is probably the most important functionality as far as I'm concerned. But all of these tabs are essentially aimed at allowing you to surface content in different ways.

So far we've concentrated mostly on YouTube, but as I mentioned above the app actually supports multiple services. They can be switched between, but only one service is active at a time.

A nice touch is that when you switch to a different service the colour of the user interface changes to reflect the fact, as you can see in the screenshots below.
 
Screenshots showing the main tab for four of the five services supported: SoundCloud, media.ccc.de, FramaTube and Bandcamp.


NewPipe does a decent job of maintaining consistency across the five services, even though they offer quite different types of media and categorisations. Part of the reason this is possible is because apart from search and accessing the media itself, much of the functionality is being provided by the app on your phone, rather than the backend service.

That's a consequence of the fact NewPipe is a read-only app. It accesses the media from the various services, but it doesn't authenticate to them, so there's no way for it to store data with the service. If you're looking for privacy then that's a feature, not a bug.

Another consequence of this is that although only one service can be active at a time, content you've subscribed to from one service is available even when you've switched to another. All of the subscriptions and playlists get mixed together into a single list, rather than being separated out by service. I really like this: it allows all of the most relevant content to be merged together and accessed easily.

Alright, let's dig a bit deeper into the user interface and find out what happens when we actually try to play some audio or video. The following screenshots show some of this functionality, but in practice there's such a wealth of options and user interface flows that there's no way I can describe all of it here.
 
Screenshots showing some of the app's functionality: the video player, video downloader, music player and the main menu.


Here we first see the video player with user comments below. As already mentioned, this is a read-only app so there's no way to add new comments. On this page there are actually two further tabs to replace comments with a list of related videos, or with the metadata related to the video.

At this point the user interface has become quite cluttered and if this is going to make it to Sailfish OS I feel it'll need to be simplified. At some point I'll have to do some proper design work to figure this all out.

From this page you can also download the video or audio to your local device, as shown in the second screenshot. This is critical functionality as far as I'm concerned. I like to download audio and video in advance while I'm at home over Wifi. Not only is this faster and cheaper than using a mobile connection, it also avoids the annoying situation when the mobile signal drops off and your video is left "buffering". That's something that happens surprisingly frequently when travelling by train in the UK.

There's also a nice music player as shown in the third screenshot. The interface is similar to that used for videos, which also means it's a bit too cluttered for my liking. But there's no shortage of juicy functionality.

Finally the screenshot on the right shows the main menu for when YouTube is the selected service. The little down arrow next to the "YouTube" text is an indication that you can switch service by tapping on the service name there.

The other menu entries are pretty self-explanatory. It's also worth noting there are nine items in this menu, which is far too many to work for a Sailfish-style pull-down menu. However the first four items are duplicates of the tabs so could be skipped and the last three could realistically be combined together leave just three items. That's more in line with what you might typical expect of a Sailfish OS menu.

It looks like this might all be workable.

I must admit that I'd not used the app before Schabi promoted it to me at FOSDEM. But it works perfectly using Android App Support on Sailfish OS and is well worth giving a go. Nonetheless the objective of this project is to make the Android app redundant for users of Sailfish OS.

This is all useful background material, but it's not actually the app itself that's interesting for us. You see the NewPipe devs have thoughtfully split the app into two parts: the user interface and the backend functionality.

The code for the former can be found in the aptly named NewPipe repository. But from a user-interface perspective Android is so different from Sailfish OS that it's unlikely we'd be able to make much use of this code.

It's the code for the latter, found in the NewPipe Extractor repository, that I'm hoping we'll be able to make better use of. This provides a Java library for searching, streaming and downloading media from the various services. It also provides an API for accessing the metadata, comments and other data associated with it.

The plan is to hook this library up to a Sailfish OS user interface built using Qt. We'll need to perform some API-boundary transmutation magic in order to get the Java library communicating effectively with the C++ front-end code. That'll be a bit of a challenge, but I'm hoping the challenge will also help make this a bit more interesting.

We'll take a deeper look at the NewPipe Extractor codebase tomorrow.