Search in sources :

Example 6 with ExtractionException

use of org.schabi.newpipe.extractor.exceptions.ExtractionException in project NewPipe by TeamNewPipe.

the class SubscriptionFragment method setupImportFromItems.

private void setupImportFromItems(final ViewGroup listHolder) {
    final View previousBackupItem = addItemView(getString(R.string.previous_export), ThemeHelper.resolveResourceIdFromAttr(getContext(), R.attr.ic_backup), listHolder);
    previousBackupItem.setOnClickListener(item -> onImportPreviousSelected());
    final int iconColor = ThemeHelper.isLightThemeSelected(getContext()) ? Color.BLACK : Color.WHITE;
    final String[] services = getResources().getStringArray(R.array.service_list);
    for (String serviceName : services) {
        try {
            final StreamingService service = NewPipe.getService(serviceName);
            final SubscriptionExtractor subscriptionExtractor = service.getSubscriptionExtractor();
            if (subscriptionExtractor == null)
                continue;
            final List<SubscriptionExtractor.ContentSource> supportedSources = subscriptionExtractor.getSupportedSources();
            if (supportedSources.isEmpty())
                continue;
            final View itemView = addItemView(serviceName, ServiceHelper.getIcon(service.getServiceId()), listHolder);
            final ImageView iconView = itemView.findViewById(android.R.id.icon1);
            iconView.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
            itemView.setOnClickListener(selectedItem -> onImportFromServiceSelected(service.getServiceId()));
        } catch (ExtractionException e) {
            throw new RuntimeException("Services array contains an entry that it's not a valid service name (" + serviceName + ")", e);
        }
    }
}
Also used : ExtractionException(org.schabi.newpipe.extractor.exceptions.ExtractionException) SubscriptionExtractor(org.schabi.newpipe.extractor.subscription.SubscriptionExtractor) StreamingService(org.schabi.newpipe.extractor.StreamingService) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) AnimationUtils.animateView(org.schabi.newpipe.util.AnimationUtils.animateView) CollapsibleView(org.schabi.newpipe.views.CollapsibleView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 7 with ExtractionException

use of org.schabi.newpipe.extractor.exceptions.ExtractionException in project NewPipe by TeamNewPipe.

the class SubscriptionsImportFragment method setupServiceVariables.

// /////////////////////////////////////////////////////////////////////////
// Subscriptions
// /////////////////////////////////////////////////////////////////////////
private void setupServiceVariables() {
    if (currentServiceId != Constants.NO_SERVICE_ID) {
        try {
            final SubscriptionExtractor extractor = NewPipe.getService(currentServiceId).getSubscriptionExtractor();
            supportedSources = extractor.getSupportedSources();
            relatedUrl = extractor.getRelatedUrl();
            instructionsString = ServiceHelper.getImportInstructions(currentServiceId);
            return;
        } catch (ExtractionException ignored) {
        }
    }
    supportedSources = Collections.emptyList();
    relatedUrl = null;
    instructionsString = 0;
}
Also used : ExtractionException(org.schabi.newpipe.extractor.exceptions.ExtractionException) SubscriptionExtractor(org.schabi.newpipe.extractor.subscription.SubscriptionExtractor)

Aggregations

ExtractionException (org.schabi.newpipe.extractor.exceptions.ExtractionException)7 StreamingService (org.schabi.newpipe.extractor.StreamingService)4 Intent (android.content.Intent)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 IOException (java.io.IOException)2 SubscriptionExtractor (org.schabi.newpipe.extractor.subscription.SubscriptionExtractor)2 SharedPreferences (android.content.SharedPreferences)1 Handler (android.os.Handler)1 StyleRes (android.support.annotation.StyleRes)1 ListPreference (android.support.v7.preference.ListPreference)1 Preference (android.support.v7.preference.Preference)1 File (java.io.File)1 ZipFile (java.util.zip.ZipFile)1 SuggestionExtractor (org.schabi.newpipe.extractor.SuggestionExtractor)1 ChannelExtractor (org.schabi.newpipe.extractor.channel.ChannelExtractor)1 ChannelInfo (org.schabi.newpipe.extractor.channel.ChannelInfo)1 ParsingException (org.schabi.newpipe.extractor.exceptions.ParsingException)1