@@ -34,9 +34,8 @@ import org.schabi.newpipe.databinding.FeedItemCarouselBinding
3434import org.schabi.newpipe.databinding.FragmentSubscriptionBinding
3535import org.schabi.newpipe.error.ErrorInfo
3636import org.schabi.newpipe.error.UserAction
37- import org.schabi.newpipe.extractor.NewPipe
37+ import org.schabi.newpipe.extractor.ServiceList
3838import org.schabi.newpipe.extractor.channel.ChannelInfoItem
39- import org.schabi.newpipe.extractor.exceptions.ExtractionException
4039import org.schabi.newpipe.fragments.BaseStateFragment
4140import org.schabi.newpipe.ktx.animate
4241import org.schabi.newpipe.local.subscription.SubscriptionViewModel.SubscriptionState
@@ -146,26 +145,16 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
146145 addMenuItemToSubmenu(importSubMenu, R .string.previous_export) { onImportPreviousSelected() }
147146 .setIcon(R .drawable.ic_backup)
148147
149- val services = requireContext().resources.getStringArray(R .array.service_list)
150- for (serviceName in services) {
151- try {
152- val service = NewPipe .getService(serviceName)
148+ for (service in ServiceList .all()) {
149+ val subscriptionExtractor = service.subscriptionExtractor ? : continue
153150
154- val subscriptionExtractor = service.subscriptionExtractor ? : continue
151+ val supportedSources = subscriptionExtractor.supportedSources
152+ if (supportedSources.isEmpty()) continue
155153
156- val supportedSources = subscriptionExtractor.supportedSources
157- if (supportedSources.isEmpty()) continue
158-
159- addMenuItemToSubmenu(importSubMenu, serviceName) {
160- onImportFromServiceSelected(service.serviceId)
161- }
162- .setIcon(ServiceHelper .getIcon(service.serviceId))
163- } catch (e: ExtractionException ) {
164- throw RuntimeException (
165- " Services array contains an entry that it's not a valid service name ($serviceName )" ,
166- e
167- )
154+ addMenuItemToSubmenu(importSubMenu, service.serviceInfo.name) {
155+ onImportFromServiceSelected(service.serviceId)
168156 }
157+ .setIcon(ServiceHelper .getIcon(service.serviceId))
169158 }
170159
171160 // -- Export --
0 commit comments