-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6421ab3
commit 1d500b8
Showing
14 changed files
with
175 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
A Qt library to interface with YouTube's InnerTube API. | ||
|
||
## Getting Started | ||
To get started, use @ref InnerTube::createContext. This example code will create an ideal, working context for you: | ||
```cpp | ||
InnerTube::instance().createContext(InnertubeClient("WEB", "2.20230718.01.00", "DESKTOP")); | ||
``` | ||
Here, a context is created around a client of the WEB type, version 2.20230718.01.00, on the DESKTOP platform.<br><br> | ||
To make a request, use @ref InnerTube::get. This example code provides a good way to test if things are working: | ||
```cpp | ||
InnertubeReply* reply = InnerTube::instance().get<InnertubeEndpoints::Next>("dQw4w9WgXcQ"); | ||
connect(reply, qOverload<const InnertubeEndpoints::Next&>(&InnertubeReply::finished), this, [](const auto& next) { | ||
qDebug() << next.response.primaryInfo.title.text; | ||
}); | ||
``` | ||
Here, a request is made to the @ref InnertubeEndpoints::Next "Next endpoint" supplied with the video ID for [the classic Rick Roll video](https://www.youtube.com/watch?v=dQw4w9WgXcQ). | ||
Once the request finishes, the response is captured and the video title is printed (which should be "Rick Astley - Never Gonna Give You Up (Official Music Video)"). | ||
|
||
## Authenticating (easily) | ||
If you wish to support logging in, you can use the authentication methods in the @ref InnerTube class. | ||
|
||
To get started, use @ref InnerTube::authenticate. This will open up a browser window on YouTube's login page that captures the necessary credentials. Once all of the necessary credentials have been captured, the signal @ref InnertubeAuthStore::authenticateSuccess is emitted, and you can do whatever you want beyond that point. The method @ref InnerTube::authStore returns the @ref InnertubeAuthStore in question.<br> | ||
**Note that this method depends on Qt Web Engine. See the [Authenticating Manually](@ref AuthenticatingManually) section if you wish to not use Qt Web Engine.** | ||
|
||
If you want to dive deeper, have a look at the @ref InnertubeAuthStore class. | ||
|
||
## Authenticating (manually) {#AuthenticatingManually} | ||
**Be warned, this not an easy process. Also, this guide will be for Firefox, but there will likely be a lot of overlap with Chromium-based browsers anyway.** | ||
|
||
### Getting the Credentials | ||
1. Go to the YouTube home page. | ||
2. Open up Developer Tools (pressing Ctrl+Shift+I or F12 works, or you can use the browser menu) and go to the Network tab. | ||
3. In the "Filter URLs" bar, type "youtubei/v1" and select any result **except for ones which contain "log_event".** | ||
4. In the "Headers" section, in the "Filter Headers" bar, type "cookie" and look for the entry that's just called "Cookie". Right click the entry and click "Copy Value". | ||
5. Inside of what you just copied, look for the values for APISID, HSID, SAPISID, SID, SSID, and VISITOR\_INFO1\_LIVE. For example, in VISITOR\_INFO1\_LIVE=xxx, the value would be xxx. | ||
|
||
### Putting It Into the Library | ||
To feed this data into the library, create a QJsonObject like so: | ||
```cpp | ||
QJsonObject obj { | ||
{ "apisid", "<YOUR APISID HERE>" }, | ||
{ "hsid", "<YOUR HSID HERE>" }, | ||
{ "sapisid", "<YOUR SAPISID HERE>" }, | ||
{ "sid", "<YOUR SID HERE>" }, | ||
{ "ssid", "<YOUR SSID HERE>" }, | ||
{ "visitorInfo", "<YOUR VISITOR_INFO1_LIVE HERE>" } | ||
}; | ||
``` | ||
Then, see steps 2 and 3 in [Restoring Authentication Data](@ref RestoringAuthenticationData). | ||
|
||
## Restoring Authentication Data {#RestoringAuthenticationData} | ||
Some facilities have been provided for making this easier. Here's the way I recommend doing it: | ||
1. Once the user has authenticated successfully, get the credentials as a JSON object using @ref InnertubeAuthStore::toJson and save it to a JSON file on the system. | ||
2. To restore the data, read the JSON file back to a QJsonObject, then provide this QJsonObject to @ref InnerTube::authenticateFromJson. | ||
3. To check if this was successful, use @ref InnerTube::hasAuthenticated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
# innertube-qt | ||
A Qt library to interface with YouTube's InnerTube API. | ||
|
||
## Building without WebEngine | ||
If you are not going to use the authentication features of this library, or just really want to disable WebEngine and do authentication manually, you can turn the ``INNERTUBE_NO_WEBENGINE`` option in the CMakeLists.txt file on. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.