Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InnerTube v2 update #153

Merged
merged 131 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
81e9951
Update InnerTube
kuylar May 19, 2024
8a9e1e8
Fix errors and warnings in Utils and Database classes
kuylar May 19, 2024
8ca3449
Add a GetLocals method since the new InnerTube doesn't have it
kuylar May 19, 2024
b14f05b
Fix errors in API endpoints
kuylar May 19, 2024
65bd24c
fix this error i caused
kuylar May 19, 2024
aae42ed
Fix the errors in the contexts
kuylar May 19, 2024
109644c
Implement recommendations endpoint
kuylar May 19, 2024
1869764
Fix empty ctor excuses
kuylar May 22, 2024
7111e39
Reimplement autocomplete
kuylar May 22, 2024
d2d51a2
Fix some API stuff
kuylar May 22, 2024
e9167e6
Fix contexts
kuylar May 22, 2024
84306a1
Fix all controllers except YoutubeController.cs
kuylar May 22, 2024
f4b9d3b
Update YoutubeController.cs
kuylar May 22, 2024
653f392
Fix all views
kuylar May 22, 2024
5d7bc01
Disable authorization
kuylar May 22, 2024
9c96bbb
Implement some renderers for the search view
kuylar May 22, 2024
d3b271e
Move renderer cshtml files to their own directory
kuylar May 22, 2024
d2272d3
Move ContainerRenderer to its own file
kuylar May 22, 2024
dfbabf2
forgot to update these two
kuylar May 22, 2024
493c620
small css fixes
kuylar May 22, 2024
2ca9f4b
Implement the renderers for the watch page
kuylar May 22, 2024
076c3c0
kuylar vs. her own code, round 2
kuylar May 23, 2024
d1ed542
New badges!
kuylar May 23, 2024
1c500d7
Playlist first video IDs
kuylar May 23, 2024
02e935b
Shelf titles
kuylar May 23, 2024
3f9379b
changed like 2 stuff
kuylar May 23, 2024
7373585
Fix playlists
kuylar May 23, 2024
3145214
Round 3
kuylar May 24, 2024
b036e54
Round... 4?
kuylar May 24, 2024
1659550
Channel avatars
kuylar May 24, 2024
44bd6fe
idrk why that exploded
kuylar May 24, 2024
11a2975
Fix the player box aspect ratio
kuylar May 24, 2024
33ad2ff
Update null renderers
kuylar May 24, 2024
3f24de5
posts in search
kuylar May 24, 2024
35be0d1
Implement search chips
kuylar May 24, 2024
75a0e61
hate css
kuylar May 24, 2024
57779fb
Round 5!
kuylar May 27, 2024
ec2b3f7
Fix authentication
kuylar May 27, 2024
b7ad158
Fix namespaces
kuylar May 27, 2024
4780500
Add parserLanguage to where its needed
kuylar May 27, 2024
67dfba7
Fix the like counter
kuylar May 27, 2024
3518330
Fix ToKMB
kuylar May 27, 2024
6096ee9
Implement ResolveUrl where needed
kuylar May 27, 2024
3c4cd6e
Update the channel header
kuylar May 27, 2024
ec20551
Round 6
kuylar May 28, 2024
a1aef03
Implement the featured tab of the channel
kuylar May 28, 2024
5f05764
Implement the shorts tab in channel
kuylar May 28, 2024
4ee7d41
Implement the community tab
kuylar May 28, 2024
e320590
Finish all channel tabs
kuylar May 28, 2024
e42fc0f
fix Utils.cs
kuylar May 28, 2024
f4ee7b6
Update LTPlayer
kuylar May 28, 2024
f7c3af7
Fix the custom CSS
kuylar May 28, 2024
c1ea68f
Fix the player returning the wrong video URLs
kuylar May 28, 2024
f5f5a82
Fix the issues in the player
kuylar May 28, 2024
18c178a
Fix the wrongly called subscribe button
kuylar May 28, 2024
12122f1
Fix search chips
kuylar May 31, 2024
95ab693
fix the ugly filters button
kuylar May 31, 2024
7b9a6ba
fix the player overflowing sideways on mobile
kuylar May 31, 2024
a4d1a44
Clamp player aspect ratios
kuylar May 31, 2024
dc32429
Add a message if only format 18 is available
kuylar May 31, 2024
35508c0
Fix the non-JS player overflowing to the side
kuylar May 31, 2024
500cb4e
Fix nullref in mixes
kuylar May 31, 2024
aef02ee
Make the mobile comment panel scrollable
kuylar May 31, 2024
7fa1371
Make the comments not overscroll to the recommendations
kuylar May 31, 2024
ea20b17
Fix mobile guide z-index
kuylar May 31, 2024
a6f37fd
Add a redirect for /{videoId}
kuylar May 31, 2024
41ce9f8
Fix trailers
kuylar May 31, 2024
889db0e
Round- wait we skipped 7? whatever Round 8
kuylar Jun 1, 2024
32c0a69
Add UI for trailers
kuylar Jun 1, 2024
aa254bb
Fix the HLS manifest url validity checker
kuylar Jun 1, 2024
b5d75db
Fix chips
kuylar Jun 1, 2024
a072601
Fix broken if statements (two of them)
kuylar Jun 1, 2024
16f849b
Fix community posts
kuylar Jun 1, 2024
3f22bac
hey look - a place to get a nullreferenceexception!
kuylar Jun 1, 2024
1ea661b
Add a small thing
kuylar Jun 1, 2024
af39d3e
Remove unused file
kuylar Jun 3, 2024
e79aea5
Add the about tab to channels
kuylar Jun 3, 2024
1c7fbef
Fix the max-lines property
kuylar Jun 3, 2024
ae80b2a
Make the tagline always max out at a single line. Also make it a norm…
kuylar Jun 3, 2024
bd44a2b
Fix community posts in search results
kuylar Jun 3, 2024
10296d3
Fix localization in channel posts
kuylar Jun 3, 2024
64c4c1e
Implement search sidebars
kuylar Jun 3, 2024
8dbdd20
Final round, if no other bugs come up
kuylar Jun 3, 2024
608f9e5
Implement exception renderers
kuylar Jun 3, 2024
5548279
Make the subscription feed API use renderercontainers
kuylar Jun 3, 2024
3f0016d
Add a null check to the playlist panel
kuylar Jun 3, 2024
19ea68d
Fix nullrefs in video caching
kuylar Jun 3, 2024
b6b36d2
Fix nullable ints in the database exploding the playlists
kuylar Jun 3, 2024
6b7eb80
Fix video player obstructing other elements
kuylar Jun 3, 2024
5ad3102
Fix broken html tags in video titles
kuylar Jun 3, 2024
226953f
Add localization to the premiere trailer text
kuylar Jun 4, 2024
6d605d2
Add a &page param to search endpoints
kuylar Jun 4, 2024
4379ce1
Make stats in channel about page wider
kuylar Jun 4, 2024
07b692a
Fix playlists
kuylar Jun 4, 2024
b53daeb
Fix wrong hyperlinks
kuylar Jun 4, 2024
5d5db00
Add editable to PlaylistVideoRendererData
kuylar Jun 6, 2024
e7a5fa6
Fix the avatar in the video player
kuylar Jun 6, 2024
72bafd4
Fix titles turning into 6px line of dots and dashes
kuylar Jun 6, 2024
3d3e6c0
Remove underline from channel tagline
kuylar Jun 6, 2024
d54a1a3
RecognitionShelfRenderer
kuylar Jun 6, 2024
143c27c
Update InnerTube for bug fixes
kuylar Jun 6, 2024
992afbf
but we stay silly
kuylar Jun 6, 2024
0c1c802
Add movieRenderer
kuylar Jun 6, 2024
d8482d9
API: Serialize enums to strings
kuylar Jun 6, 2024
6b462c2
API: Make the UserData folllow the rest of the naming scheme
kuylar Jun 6, 2024
4091a82
That breaks the entire program and wipes the database clean. Use Json…
kuylar Jun 6, 2024
48a9252
API: Add editable field to playlists
kuylar Jun 6, 2024
9c46a45
API: Fix all the nullrefs in the playlist endpoint
kuylar Jun 6, 2024
6e60661
API: Add exact publish date to the subscription feed videos
kuylar Jun 6, 2024
04ab5f2
Make sure the search page doesnt explode when the sidebar throws an e…
kuylar Jun 6, 2024
1f74404
Fix the trailer screen eating all the mouse events
kuylar Jun 6, 2024
b20273b
Make it so videos without valid HLS manifests has UseHls = false
kuylar Jun 6, 2024
b0a736c
Fix the comment headers
kuylar Jun 6, 2024
745fc03
Make the version have the major version in it
kuylar Jun 6, 2024
a44f0eb
Fix wrong renderer name
kuylar Jul 29, 2024
aeea81d
Fix nullref in /api/playlist with LT playlists
kuylar Jul 29, 2024
7fb3220
Add video player error messages to the channel page
kuylar Jul 29, 2024
996523f
Fix messagerenderer in playlist sidebar
kuylar Jul 29, 2024
d0e4410
Implement all sidebars
kuylar Jul 29, 2024
b342728
Add query corrector
kuylar Jul 29, 2024
68ff040
guess whos stupid
kuylar Jul 29, 2024
39d2d5e
Fix playlist APIs
kuylar Aug 1, 2024
06226a2
Fix channel continuation API
kuylar Aug 2, 2024
5ae106b
Bump InnerTube
kuylar Aug 2, 2024
970fafc
Fix MPD manifests
kuylar Aug 5, 2024
3f6efe7
Fix the whole video page crashing if there are no storyboards
kuylar Aug 5, 2024
1b9db19
yea
kuylar Aug 5, 2024
a434b38
Delete the nojs quality switcher as YouTube now only provides itag 18
kuylar Aug 5, 2024
9f76075
Add the new shelf renderer
kuylar Aug 5, 2024
a63c0a1
Fix the promoted video player
kuylar Aug 5, 2024
77ea256
Fix the age restriction button
kuylar Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make the subscription feed API use renderercontainers
  • Loading branch information
kuylar committed Jun 3, 2024
commit 5548279e836edd5fcba9d0fb45136597bb82995e
62 changes: 58 additions & 4 deletions LightTube/Controllers/OauthApiController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Net;
using InnerTube;
using InnerTube.Models;
using InnerTube.Protobuf;
using InnerTube.Renderers;
using LightTube.ApiModels;
using LightTube.Attributes;
Expand Down Expand Up @@ -217,22 +218,75 @@ public async Task<ApiResponse<Dictionary<string, DatabaseChannel>>> GetSubscript
[Route("feed")]
[HttpGet]
[ApiAuthorization("subscriptions.read")]
public async Task<ApiResponse<FeedVideo[]>> GetSubscriptionFeed(
public async Task<ApiResponse<IEnumerable<RendererContainer>>> GetSubscriptionFeed(
bool includeNonNotification = true, int limit = 10, int skip = 0)
{
DatabaseUser? user = await DatabaseManager.Oauth2.GetUserFromHttpRequest(Request);
if (user is null)
return Error<FeedVideo[]>("Unauthorized", 401, HttpStatusCode.Unauthorized);
return Error<IEnumerable<RendererContainer>>("Unauthorized", 401, HttpStatusCode.Unauthorized);

Dictionary<string, string> avatars = [];
foreach (string id in user.Subscriptions.Keys)
{
DatabaseChannel? channel = DatabaseManager.Cache.GetChannel(id);
if (channel is null) continue;
avatars.Add(id, channel.IconUrl);
}

FeedVideo[] feed = includeNonNotification
? await YoutubeRss.GetMultipleFeeds(user.Subscriptions.Keys)
: await YoutubeRss.GetMultipleFeeds(user.Subscriptions.Where(x =>
x.Value == SubscriptionType.NOTIFICATIONS_OFF).Select(x => x.Key));
x.Value == SubscriptionType.NOTIFICATIONS_ON).Select(x => x.Key));

feed = feed.Skip(skip).Take(limit).ToArray();

IEnumerable<RendererContainer> renderers = feed.Select(x => new RendererContainer
{
Type = "video",
OriginalType = "lightTubeFeedVideo",
Data = new VideoRendererData
{
VideoId = x.Id,
Title = x.Title,
Thumbnails =
[
new Thumbnail
{
Url = x.Thumbnail,
Width = 0,
Height = 0
}
],
Author = new Channel("en",
x.ChannelId,
x.ChannelName,
null,
avatars.TryGetValue(x.ChannelId, out string? avatarUrl)
? [
new Thumbnail
{
Url = avatarUrl,
Width = 0,
Height = 0
}
]
: null,
null,
null),
Duration = TimeSpan.Zero,
PublishedText = x.PublishedDate.ToString("D"),
RelativePublishedDate = Utils.ToRelativePublishedDate(x.PublishedDate),
ViewCountText =
string.Format(LocalizationManager.GetFromHttpContext(HttpContext).GetRawString("channel.about.views"), x.ViewCount.ToString("N0")),
ViewCount = x.ViewCount,
Badges = [],
Description = x.Description,
PremiereStartTime = null
}
});

ApiUserData? userData = ApiUserData.GetFromDatabaseUser(user);
return new ApiResponse<FeedVideo[]>(feed, userData);
return new ApiResponse<IEnumerable<RendererContainer>>(renderers, userData);
}

[Route("subscriptions")]
Expand Down
23 changes: 23 additions & 0 deletions LightTube/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,4 +709,27 @@ public static string GetAspectRatio(WatchContext context)
? Math.Max(1f, Math.Min((float)format.Width / (float)format.Height, 3)).ToString(CultureInfo.InvariantCulture)
: "16/9";
}

public static string ToRelativePublishedDate(DateTimeOffset date)
{
TimeSpan diff = DateTimeOffset.Now - date;
int totalDays = (int)Math.Floor(diff.TotalDays);
switch (totalDays)
{
case > 365:
return $"-{Math.Floor(diff.TotalDays / 365f)}Y";
case > 30:
return $"-{Math.Floor(diff.TotalDays / 30f)}M";
case > 7:
return $"-{Math.Floor(diff.TotalDays / 7f)}W";
case > 0:
return $"-{Math.Floor(diff.TotalDays)}D";
}

if (diff.Hours >= 1)
return $"-{diff.Hours}h";
if (diff.Minutes >= 1)
return $"-{diff.Minutes}m";
return $"-{diff.Seconds}m";
}
}