4040import org .schabi .newpipe .extractor .MetaInfo ;
4141import org .schabi .newpipe .extractor .NewPipe ;
4242import org .schabi .newpipe .extractor .Page ;
43+ import org .schabi .newpipe .extractor .StreamingService ;
4344import org .schabi .newpipe .extractor .channel .ChannelInfo ;
4445import org .schabi .newpipe .extractor .channel .tabs .ChannelTabInfo ;
4546import org .schabi .newpipe .extractor .comments .CommentsInfo ;
4647import org .schabi .newpipe .extractor .comments .CommentsInfoItem ;
48+ import org .schabi .newpipe .extractor .kiosk .KioskExtractor ;
4749import org .schabi .newpipe .extractor .kiosk .KioskInfo ;
4850import org .schabi .newpipe .extractor .linkhandler .ListLinkHandler ;
4951import org .schabi .newpipe .extractor .playlist .PlaylistInfo ;
5355import org .schabi .newpipe .extractor .suggestion .SuggestionExtractor ;
5456import org .schabi .newpipe .util .text .TextLinkifier ;
5557
58+ import java .lang .reflect .Constructor ;
5659import java .util .Collections ;
5760import java .util .List ;
5861
@@ -194,7 +197,17 @@ public static Single<KioskInfo> getKioskInfo(final int serviceId,
194197 final String url ,
195198 final boolean forceLoad ) {
196199 return checkCache (forceLoad , serviceId , url , InfoCache .Type .KIOSK ,
197- Single .fromCallable (() -> KioskInfo .getInfo (NewPipe .getService (serviceId ), url )));
200+ Single .fromCallable (() -> {
201+ try {
202+ return KioskInfo .getInfo (NewPipe .getService (serviceId ), url );
203+ } catch (final Exception e ) {
204+ if (e .getMessage () != null
205+ && e .getMessage ().contains ("Could not get channel name" )) {
206+ return getKioskInfoFallback (serviceId , url );
207+ }
208+ throw e ;
209+ }
210+ }));
198211 }
199212
200213 public static Single <InfoItemsPage <StreamInfoItem >> getMoreKioskItems (final int serviceId ,
@@ -204,6 +217,33 @@ public static Single<InfoItemsPage<StreamInfoItem>> getMoreKioskItems(final int
204217 KioskInfo .getMoreItems (NewPipe .getService (serviceId ), url , nextPage ));
205218 }
206219
220+ private static KioskInfo getKioskInfoFallback (final int serviceId , final String url )
221+ throws Exception {
222+ final StreamingService service = NewPipe .getService (serviceId );
223+ final KioskExtractor extractor = service .getKioskList ().getExtractorByUrl (url , null );
224+ extractor .fetchPage ();
225+
226+ String name ;
227+ try {
228+ name = extractor .getName ();
229+ } catch (final Exception ignored ) {
230+ name = extractor .getId ();
231+ }
232+
233+ final Constructor <KioskInfo > constructor = KioskInfo .class
234+ .getDeclaredConstructor (int .class , ListLinkHandler .class , String .class );
235+ constructor .setAccessible (true );
236+ final KioskInfo info = constructor .newInstance (extractor .getServiceId (),
237+ extractor .getLinkHandler (), name );
238+
239+ final org .schabi .newpipe .extractor .ListExtractor .InfoItemsPage <StreamInfoItem > itemsPage =
240+ org .schabi .newpipe .extractor .utils .ExtractorHelper
241+ .getItemsPageOrLogError (info , extractor );
242+ info .setRelatedItems (itemsPage .getItems ());
243+ info .setNextPage (itemsPage .getNextPage ());
244+ return info ;
245+ }
246+
207247 /*//////////////////////////////////////////////////////////////////////////
208248 // Cache
209249 //////////////////////////////////////////////////////////////////////////*/
0 commit comments