Skip to content

Commit

Permalink
feat: Add TVHTML5 InnerTube client
Browse files Browse the repository at this point in the history
+ Update `ANDROID` version.
  • Loading branch information
LuanRT committed Oct 26, 2024
1 parent 91d3081 commit b45609a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/core/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ export default class Player {
case 'WEB_KIDS':
url_components.searchParams.set('cver', Constants.CLIENTS.WEB_KIDS.VERSION);
break;
case 'ANDROID':
url_components.searchParams.set('cver', Constants.CLIENTS.ANDROID.VERSION);
break;
case 'ANDROID_MUSIC':
url_components.searchParams.set('cver', Constants.CLIENTS.YTMUSIC_ANDROID.VERSION);
break;
case 'TVHTML5_SIMPLY_EMBEDDED_PLAYER':
url_components.searchParams.set('cver', Constants.CLIENTS.TV_EMBEDDED.VERSION);
break;
Expand Down
1 change: 1 addition & 0 deletions src/core/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum ClientType {
ANDROID = 'ANDROID',
ANDROID_MUSIC = 'ANDROID_MUSIC',
ANDROID_CREATOR = 'ANDROID_CREATOR',
TV = 'TVHTML5',
TV_EMBEDDED = 'TVHTML5_SIMPLY_EMBEDDED_PLAYER',
WEB_EMBEDDED = 'WEB_EMBEDDED_PLAYER',
WEB_CREATOR = 'WEB_CREATOR'
Expand Down
2 changes: 1 addition & 1 deletion src/types/Misc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SessionOptions } from '../core/index.js';

export type InnerTubeConfig = SessionOptions;
export type InnerTubeClient = 'IOS' | 'WEB' | 'ANDROID' | 'YTMUSIC' | 'YTMUSIC_ANDROID' | 'YTSTUDIO_ANDROID' | 'TV_EMBEDDED' | 'YTKIDS' | 'WEB_EMBEDDED' | 'WEB_CREATOR';
export type InnerTubeClient = 'IOS' | 'WEB' | 'ANDROID' | 'YTMUSIC' | 'YTMUSIC_ANDROID' | 'YTSTUDIO_ANDROID' | 'TV' | 'TV_EMBEDDED' | 'YTKIDS' | 'WEB_EMBEDDED' | 'WEB_CREATOR';

export type UploadDate = 'all' | 'hour' | 'today' | 'week' | 'month' | 'year';
export type SearchType = 'all' | 'video' | 'channel' | 'playlist' | 'movie';
Expand Down
12 changes: 9 additions & 3 deletions src/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export const CLIENTS = Object.freeze({
ANDROID: {
NAME_ID: '3',
NAME: 'ANDROID',
VERSION: '18.48.37',
VERSION: '19.35.36',
SDK_VERSION: 33,
USER_AGENT: 'com.google.android.youtube/18.48.37(Linux; U; Android 13; en_US; sdk_gphone64_x86_64 Build/UPB4.230623.005) gzip'
USER_AGENT: 'com.google.android.youtube/19.35.36(Linux; U; Android 13; en_US; SM-S908E Build/TP1A.220624.014) gzip'
},
YTSTUDIO_ANDROID: {
NAME_ID: '14',
Expand All @@ -65,6 +65,12 @@ export const CLIENTS = Object.freeze({
NAME: 'ANDROID_MUSIC',
VERSION: '5.34.51'
},
TV: {
NAME_ID: '7',
NAME: 'TVHTML5',
VERSION: '7.20241016.15.00',
USER_AGENT: 'Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version'
},
TV_EMBEDDED: {
NAME_ID: '85',
NAME: 'TVHTML5_SIMPLY_EMBEDDED_PLAYER',
Expand Down Expand Up @@ -99,4 +105,4 @@ export const INNERTUBE_HEADERS_BASE = Object.freeze({
'content-type': 'application/json'
});

export const SUPPORTED_CLIENTS = [ 'IOS', 'WEB', 'YTKIDS', 'YTMUSIC', 'ANDROID', 'YTSTUDIO_ANDROID', 'YTMUSIC_ANDROID', 'TV_EMBEDDED', 'WEB_EMBEDDED', 'WEB_CREATOR' ];
export const SUPPORTED_CLIENTS = [ 'IOS', 'WEB', 'YTKIDS', 'YTMUSIC', 'ANDROID', 'YTSTUDIO_ANDROID', 'YTMUSIC_ANDROID', 'TV', 'TV_EMBEDDED', 'WEB_EMBEDDED', 'WEB_CREATOR' ];
6 changes: 6 additions & 0 deletions src/utils/HTTPClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ export default class HTTPClient {
ctx.client.clientFormFactor = 'SMALL_FORM_FACTOR';
ctx.client.clientName = Constants.CLIENTS.YTSTUDIO_ANDROID.NAME;
break;
case 'TV': {
ctx.client.clientVersion = Constants.CLIENTS.TV.VERSION;
ctx.client.clientName = Constants.CLIENTS.TV.NAME;
ctx.client.userAgent = Constants.CLIENTS.TV.USER_AGENT;
break;
}
case 'TV_EMBEDDED':
ctx.client.clientName = Constants.CLIENTS.TV_EMBEDDED.NAME;
ctx.client.clientVersion = Constants.CLIENTS.TV_EMBEDDED.VERSION;
Expand Down

0 comments on commit b45609a

Please sign in to comment.