@@ -57,6 +57,9 @@ public class ItagItem {
5757 new ItagItem (137 , VIDEO_ONLY , MPEG_4 , "1080p" ),
5858 new ItagItem (299 , VIDEO_ONLY , MPEG_4 , "1080p60" , 60 ),
5959 new ItagItem (266 , VIDEO_ONLY , MPEG_4 , "2160p" ),
60+ new ItagItem (402 , VIDEO_ONLY , MPEG_4 , "4320p" ), // can be 4320p60 as well
61+ new ItagItem (571 , VIDEO_ONLY , MPEG_4 , "4320p" ), // can be 4320p60 HDR as well (1La4QzGeaaQ)
62+ new ItagItem (402 , VIDEO_ONLY , MPEG_4 , "4320p60" ),
6063
6164 new ItagItem (278 , VIDEO_ONLY , WEBM , "144p" ),
6265 new ItagItem (242 , VIDEO_ONLY , WEBM , "240p" ),
@@ -67,27 +70,17 @@ public class ItagItem {
6770 new ItagItem (247 , VIDEO_ONLY , WEBM , "720p" ),
6871 new ItagItem (248 , VIDEO_ONLY , WEBM , "1080p" ),
6972 new ItagItem (271 , VIDEO_ONLY , WEBM , "1440p" ),
70- // #272 is either 3840x2160 (e.g. RtoitU2A-3E) or 7680x4320 (sLprVF6d7Ug)
71- new ItagItem (272 , VIDEO_ONLY , WEBM , "2160p" ),
7273 new ItagItem (302 , VIDEO_ONLY , WEBM , "720p60" , 60 ),
7374 new ItagItem (303 , VIDEO_ONLY , WEBM , "1080p60" , 60 ),
7475 new ItagItem (308 , VIDEO_ONLY , WEBM , "1440p60" , 60 ),
7576 new ItagItem (313 , VIDEO_ONLY , WEBM , "2160p" ),
76- new ItagItem (315 , VIDEO_ONLY , WEBM , "2160p60" , 60 )
77+ new ItagItem (315 , VIDEO_ONLY , WEBM , "2160p60" , 60 ),
78+ new ItagItem (272 , VIDEO_ONLY , WEBM , "4320p60" , 60 )
7779 };
7880 /*//////////////////////////////////////////////////////////////////////////
7981 // Utils
8082 //////////////////////////////////////////////////////////////////////////*/
8183
82- public static boolean isSupported (int itag ) {
83- for (ItagItem item : ITAG_LIST ) {
84- if (itag == item .id ) {
85- return true ;
86- }
87- }
88- return false ;
89- }
90-
9184 public static ItagItem getItag (int itagId ) throws ParsingException {
9285 for (ItagItem item : ITAG_LIST ) {
9386 if (itagId == item .id ) {
@@ -97,6 +90,50 @@ public static ItagItem getItag(int itagId) throws ParsingException {
9790 throw new ParsingException ("itag=" + itagId + " not supported" );
9891 }
9992
93+ public static ItagItem getItag (int itagId , int averageBitrate , int fps , String qualityLabel , String mimeType ) throws ParsingException {
94+
95+ String [] split = mimeType .split (";" )[0 ].split ("/" );
96+ String streamType = split [0 ];
97+ String fileType = split [1 ];
98+ String codec = mimeType .split ("\" " )[1 ];
99+
100+ MediaFormat format = null ;
101+ ItagType itagType = null ;
102+
103+ if (codec .contains ("," ))
104+ itagType = VIDEO ;
105+ else {
106+ if (streamType .equals ("video" ))
107+ itagType = VIDEO_ONLY ;
108+ if (streamType .equals ("audio" ))
109+ itagType = AUDIO ;
110+ }
111+
112+ if (itagType == AUDIO ) {
113+ if (fileType .equals ("mp4" ) && (codec .startsWith ("m4a" ) || codec .startsWith ("mp4a" ) ))
114+ format = M4A ;
115+ if (fileType .startsWith ("webm" ) && codec .equals ("opus" ))
116+ format = WEBMA_OPUS ;
117+ }
118+
119+ if (itagType == VIDEO ) {
120+ if (fileType .equals ("mp4" ))
121+ format = MPEG_4 ;
122+ }
123+
124+ if (itagType == VIDEO_ONLY ) {
125+ if (fileType .equals ("mp4" ))
126+ format = MPEG_4 ;
127+ if (fileType .equals ("webm" ))
128+ format = WEBM ;
129+ }
130+
131+ if (itagType == null || format == null )
132+ throw new ParsingException ("Unknown mimeType: " + mimeType );
133+
134+ return itagType == AUDIO ? new ItagItem (itagId , itagType , format , Math .round (averageBitrate / 1024f )) : new ItagItem (itagId , itagType , format , qualityLabel , fps );
135+ }
136+
100137 /*//////////////////////////////////////////////////////////////////////////
101138 // Contructors and misc
102139 //////////////////////////////////////////////////////////////////////////*/
0 commit comments