@Ignore public static SubscriptionEntity from(@NonNull ChannelInfo info) { SubscriptionEntity result = new SubscriptionEntity(); result.setServiceId(info.getServiceId()); result.setUrl(info.getUrl()); result.setData(info.getName(), info.getAvatarUrl(), info.getDescription(), info.getSubscriberCount()); return result; } }
@Override public void handleResult(@NonNull ChannelInfo result) { super.handleResult(result); headerRootLayout.setVisibility(View.VISIBLE); imageLoader.displayImage(result.getBannerUrl(), headerChannelBanner, ImageDisplayConstants.DISPLAY_BANNER_OPTIONS); imageLoader.displayImage(result.getAvatarUrl(), headerAvatarView, ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS); headerSubscribersTextView.setVisibility(View.VISIBLE); if (result.getSubscriberCount() >= 0) { headerSubscribersTextView.setText(Localization.localizeSubscribersCount(activity, result.getSubscriberCount())); } else { headerSubscribersTextView.setText(R.string.subscribers_count_not_available); } if (menuRssButton != null) menuRssButton.setVisible(!TextUtils.isEmpty(result.getFeedUrl())); playlistCtrl.setVisibility(View.VISIBLE); if (!result.getErrors().isEmpty()) { showSnackBarError(result.getErrors(), UserAction.REQUESTED_CHANNEL, NewPipe.getNameOfService(result.getServiceId()), result.getUrl(), 0); } if (disposables != null) disposables.clear(); if (subscribeButtonMonitor != null) subscribeButtonMonitor.dispose(); updateSubscription(result); monitorSubscription(result); headerPlayAllButton.setOnClickListener( view -> NavigationHelper.playOnMainPlayer(activity, getPlayQueue())); headerPopupButton.setOnClickListener( view -> NavigationHelper.playOnPopupPlayer(activity, getPlayQueue())); headerBackgroundButton.setOnClickListener( view -> NavigationHelper.playOnBackgroundPlayer(activity, getPlayQueue())); }
@Override public CompletableSource apply(@NonNull List<SubscriptionEntity> subscriptionEntities) { if (DEBUG) Log.d(TAG, "updateChannelInfo() called with: subscriptionEntities = [" + subscriptionEntities + "]"); if (subscriptionEntities.size() == 1) { SubscriptionEntity subscription = subscriptionEntities.get(0); // Subscriber count changes very often, making this check almost unnecessary. // Consider removing it later. if (!isSubscriptionUpToDate(info, subscription)) { subscription.setData(info.getName(), info.getAvatarUrl(), info.getDescription(), info.getSubscriberCount()); return Completable.fromRunnable(() -> subscriptionTable().update(subscription)); } } return Completable.complete(); } };
ChannelInfo info = new ChannelInfo(extractor.getServiceId(), extractor.getLinkHandler(), extractor.getName()); info.setAvatarUrl(extractor.getAvatarUrl()); } catch (Exception e) { info.addError(e); info.setBannerUrl(extractor.getBannerUrl()); } catch (Exception e) { info.addError(e); info.setFeedUrl(extractor.getFeedUrl()); } catch (Exception e) { info.addError(e); info.setRelatedItems(itemsPage.getItems()); info.setNextPageUrl(itemsPage.getNextPageUrl()); info.setSubscriberCount(extractor.getSubscriberCount()); } catch (Exception e) { info.addError(e); info.setDescription(extractor.getDescription()); } catch (Exception e) { info.addError(e); info.setDonationLinks(extractor.getDonationLinks()); } catch (Exception e) {
public static Single<ChannelInfo> getChannelInfo(final int serviceId, final String url, boolean forceLoad) { checkServiceId(serviceId); return checkCache(forceLoad, serviceId, url, Single.fromCallable(() -> ChannelInfo.getInfo(NewPipe.getService(serviceId), url))); }
@Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if(activity != null && useAsFrontPage && isVisibleToUser) { setTitle(currentInfo != null ? currentInfo.getName() : name); } }
private void openRssFeed() { final ChannelInfo info = currentInfo; if(info != null) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(info.getFeedUrl())); startActivity(intent); } }
public static Single<InfoItemsPage> getMoreChannelItems(final int serviceId, final String url, final String nextStreamsUrl) { checkServiceId(serviceId); return Single.fromCallable(() -> ChannelInfo.getMoreItems(NewPipe.getService(serviceId), url, nextStreamsUrl)); }
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException { return getInfo(NewPipe.getServiceByUrl(url), url); }
private Consumer<Notification<ChannelInfo>> getNotificationsConsumer() { return notification -> { if (notification.isOnNext()) { String name = notification.getValue().getName(); eventListener.onItemCompleted(!TextUtils.isEmpty(name) ? name : ""); } else if (notification.isOnError()) { final Throwable error = notification.getError(); final Throwable cause = error.getCause(); if (error instanceof IOException) { throw (IOException) error; } else if (cause != null && cause instanceof IOException) { throw (IOException) cause; } eventListener.onItemCompleted(""); } }; }
private boolean isSubscriptionUpToDate(final ChannelInfo info, final SubscriptionEntity entity) { return info.getUrl().equals(entity.getUrl()) && info.getServiceId() == entity.getServiceId() && info.getName().equals(entity.getName()) && info.getAvatarUrl().equals(entity.getAvatarUrl()) && info.getDescription().equals(entity.getDescription()) && info.getSubscriberCount() == entity.getSubscriberCount(); } }
public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException { ChannelExtractor extractor = service.getChannelExtractor(url); extractor.fetchPage(); return getInfo(extractor); }
private Consumer<List<SubscriptionEntity>> getSubscribeUpdateMonitor(final ChannelInfo info) { return (List<SubscriptionEntity> subscriptionEntities) -> { if (DEBUG) Log.d(TAG, "subscriptionService.subscriptionTable.doOnNext() called with: subscriptionEntities = [" + subscriptionEntities + "]"); if (subscribeButtonMonitor != null) subscribeButtonMonitor.dispose(); if (subscriptionEntities.isEmpty()) { if (DEBUG) Log.d(TAG, "No subscription to this channel!"); SubscriptionEntity channel = new SubscriptionEntity(); channel.setServiceId(info.getServiceId()); channel.setUrl(info.getUrl()); channel.setData(info.getName(), info.getAvatarUrl(), info.getDescription(), info.getSubscriberCount()); subscribeButtonMonitor = monitorSubscribeButton(headerSubscribeButton, mapOnSubscribe(channel)); } else { if (DEBUG) Log.d(TAG, "Found subscription to this channel!"); final SubscriptionEntity subscription = subscriptionEntities.get(0); subscribeButtonMonitor = monitorSubscribeButton(headerSubscribeButton, mapOnUnsubscribe(subscription)); } }; }