-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace YouTube API with piped API
- Loading branch information
Kingkor Roy Tirtho
committed
May 14, 2023
1 parent
edb3d47
commit 1ecc36d
Showing
10 changed files
with
291 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:catcher/catcher.dart'; | ||
import 'package:http/http.dart'; | ||
import 'package:piped_client/piped_client.dart'; | ||
import 'package:spotube/entities/cache_track.dart'; | ||
import 'package:spotube/models/logger.dart'; | ||
import 'package:spotube/models/track.dart'; | ||
import 'package:spotube/provider/user_preferences_provider.dart'; | ||
import 'package:spotube/services/youtube.dart'; | ||
import 'package:spotube/utils/duration.dart'; | ||
|
||
extension PipedSearchItemExtension on PipedSearchItem { | ||
static PipedSearchItemStream fromCacheTrack(CacheTrack cacheTrack) { | ||
return PipedSearchItemStream( | ||
type: PipedSearchItemType.stream, | ||
url: "watch?v=${cacheTrack.id}", | ||
title: cacheTrack.title, | ||
uploaderName: cacheTrack.author, | ||
uploaderUrl: "/channel/${cacheTrack.channelId}", | ||
uploaded: -1, | ||
uploadedDate: cacheTrack.uploadDate ?? "", | ||
shortDescription: cacheTrack.description, | ||
isShort: false, | ||
thumbnail: "", | ||
duration: cacheTrack.duration != null | ||
? tryParseDuration(cacheTrack.duration!) ?? Duration.zero | ||
: Duration.zero, | ||
uploaderAvatar: "", | ||
uploaderVerified: false, | ||
views: cacheTrack.engagement.viewCount, | ||
); | ||
} | ||
} | ||
|
||
extension PipedStreamResponseExtension on PipedStreamResponse { | ||
static Future<PipedStreamResponse> fromBackendTrack( | ||
BackendTrack track) async { | ||
return await PipedSpotube.client.streams(track.youtubeId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.