-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from internet4000/feat/track-dead-link
feat: add notification on track when its media is not available
- Loading branch information
Showing
14 changed files
with
128 additions
and
26 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
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
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
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
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
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,38 @@ | ||
import Ember from 'ember'; | ||
import config from 'radio4000/config/environment'; | ||
const {debug} = Ember; | ||
|
||
const fetchYoutubeTrack = async (ytid, fields) => { | ||
if (!ytid) { | ||
throw Error('You need to provide a youtube video to fetchYoutubeTrack') | ||
} | ||
if (!fields) { | ||
fields = `items(id,snippet,contentDetails,statistics)&part=snippet,contentDetails,statistics`; | ||
} | ||
|
||
let rootUrl = `https://www.googleapis.com/youtube/v3/videos?key=${config.youtubeApiKey}` | ||
let url = rootUrl + `&id=${ytid}&fields=${fields}` | ||
let response = await fetch(url); | ||
let data = await response.json(); | ||
return data | ||
} | ||
|
||
const fetchTitle = async function (ytid) { | ||
let data = await fetchYoutubeTrack(ytid, 'items(id,snippet(title))&part=snippet'); | ||
|
||
if (!data.items.length) { | ||
debug('Could not find title for track'); | ||
return; | ||
} | ||
|
||
return data.items[0] && data.items[0].snippet.title | ||
} | ||
|
||
const fetchTrackAvailability = async function (ytid) { | ||
// let data = await fetchYoutubeTrack(ytid, 'items(id,status)&part=status') | ||
let data = await fetchYoutubeTrack(ytid, 'items(id,snippet(title))&part=snippet') | ||
|
||
return Boolean(data.items.length) | ||
} | ||
|
||
export {fetchTitle, fetchTrackAvailability}; |
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