amugofjava / podcast_search

A simple library providing programmatic access to the iTunes search API for podcasts.
MIT License
41 stars 26 forks source link

[BUG]: Bad request on loading feed from url #18

Closed Abolfazl-MI closed 7 months ago

Abolfazl-MI commented 7 months ago

what happened ?

I have created complete podcast player base on this package but from last week I got Bad Request exception and it dosent load from feed of the podcast , its not matter which! not every podcast load from feed url and episodes not showing

steps to produce of bug

my provider function which load podcast from feed URL

 Future<podcast.Podcast> loadPodcastFromFeed({required String feedUrl}) async {
    return await podcast.Podcast.loadFeed(url: feedUrl);
  }

this is where I got bad request

details

. flutter : 3.16.5 . podcast_search: ^0.6.1

amugofjava commented 7 months ago

Hi @Abolfazl-MI,

Could you please send me a few example URLs that are not working so I can test them?

I also notice that you are a few versions behind current podcast_search. Have you tried the latest version?

Abolfazl-MI commented 7 months ago

Hi @amugofjava thanks for your warm answer I have consider updating the version but still not loading the podcast episodes in home screen I have list of podcasts which user has subscribed , I save a model in isar the model is this

@collection
class SubscriptionModel {
  Id? id = Isar.autoIncrement;
  // store the track name
  String? trackName;
  // track artwork ulr
  String? artWorkUrl;
  // subscription link => feed link
  String? subscriptionUrl;
  // constructor
  SubscriptionModel(
      {this.artWorkUrl, this.subscriptionUrl, this.trackName, this.id});

  /// to entity
  SubscriptionEntity toEntity() => SubscriptionEntity(
      id: id,
      artWorkUrl: artWorkUrl,
      subscriptionUrl: subscriptionUrl,
      trackName: trackName);

  /// from Entity
  factory SubscriptionModel.fromEntity(SubscriptionEntity entity) =>
      SubscriptionModel(
          id: entity.id,
          artWorkUrl: entity.artWorkUrl,
          subscriptionUrl: entity.subscriptionUrl,
          trackName: entity.trackName);
}

and in home I have grid view of that when User press on it navigate to single page and add event to bloc

context.read<SinglePodcastBloc>().add(LoadPodcastFromFeed(
          ModalRoute.of(context)!.settings.arguments as String));

then the bloc use repository to call the that method I have mentioned above

  _loadFromFeed(
      LoadPodcastFromFeed event, Emitter<SinglePodcastState> emit) async {
    emit(SinglePodLoadingState());
    LoadEpisodeFromFeedParam param =
        LoadEpisodeFromFeedParam(feedUrl: event.feedUrl);
    // DataState<SinglePodcastEntity> result =
    //     await compute(isoloateloadPodcastFromFeed, param);
    DataState<SinglePodcastEntity> result =
        await podcastRepository.loadPodcastFromFeed(feedUrl: event.feedUrl);
    if (result is DataSuccess) {
      audioHandler.clearPlayList();
      CreateAudiSourceParams audiSourceParams = CreateAudiSourceParams(
          episodes: result.data?.episodes ?? [],
          genre: result.data?.genres?.first.name ?? '');
      List<MediaItem> mediaItems =
          await compute(createAudioSource, audiSourceParams);
      await locator<AudioHandler>().addQueueItems(mediaItems);
      emit(SinglePodLoaded(result.data!, []));
    }
    return emit(SinglePodError('SomeThing went wrong'));
  }

the code impl in repository is that I have mentioned above

sample url income to load froom feed is https://www.hubermanlab.com and its from feedUrl of class you have defindd

Abolfazl-MI commented 7 months ago

@amugofjava if you need to know more I could add u on my project but I can not public it

amugofjava commented 7 months ago

@Abolfazl-MI,

I have tried loading the feed from https://www.hubermanlab.com and it worked for me. Specifically, the RSS feed is:

var podcast = await Podcast.loadFeed(url: 'https://feeds.megaphone.fm/hubermanlab');

This did return a list of episodes. It's difficult to tell from your code snippet exactly what is happening. Can you post the feed URL your app is trying to load and any exception errors you're getting back?

Abolfazl-MI commented 7 months ago

thanks @amugofjava that was my major mistake in saving links I'm so sorry bothering you

amugofjava commented 7 months ago

OK, no problem. Glad you got it fixed.