fromPlayableItem static method

BaseItem fromPlayableItem(
  1. PlayableItem item
)

Converts any PlayableItem to BaseItem using the interface fields.

Implementation

static BaseItem fromPlayableItem(PlayableItem item) {
  try {
    if (item is AppReleaseItem) return fromAppReleaseItem(item);
    if (item is AppMediaItem) return fromAppMediaItem(item);
    return BaseItem(
      id: item.id,
      name: item.name,
      description: item.description ?? '',
      imgUrl: item.imgUrl,
      galleryUrls: item.galleryUrls,
      url: item.streamUrl,
      duration: item.duration,
      state: item.state,
      permaUrl: '',
      ownerId: item.ownerId ?? '',
      ownerName: item.ownerName,
      categories: item.categories ?? [],
      metaOwner: null,
      publishedYear: item.publishedYear ?? 0,
    );
  } catch (e, st) {
    NeomErrorLogger.recordError(e, st, module: 'neom_commons', operation: 'fromPlayableItem');
    throw Exception('Error mapping PlayableItem to BaseItem: $e');
  }
}