Skip to content

Commit

Permalink
Remove some of the old boilerplate project info, add basic youtube pl…
Browse files Browse the repository at this point in the history
…aylist search
  • Loading branch information
nukeop committed Jan 23, 2017
1 parent 131de4c commit e974093
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 34 deletions.
2 changes: 1 addition & 1 deletion app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Hello Electron React!</title>
<title>nuclear music player</title>
<script>
(function() {
if (!process.env.HOT) {
Expand Down
74 changes: 49 additions & 25 deletions app/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default class Home extends Component {
var _this = this;
this.state.searchTerms = document.getElementById("searchField").value;
this.state.songList = [];
var tempList = [];
var searchResults = [];

if (searchSources.length < 1) {
this.showAlertInfo("Please select a source.");
Expand All @@ -205,37 +205,61 @@ export default class Home extends Component {
_this.songSearchStartCallback();

if (searchSources.indexOf('youtube') >= 0){
Axios.get(this.prepareUrl("https://www.googleapis.com/youtube/v3/search?part=id,snippet&maxResults=50&q="+this.state.searchTerms))
Axios.get(this.prepareUrl("https://www.googleapis.com/youtube/v3/search?part=id,snippet&type=video&maxResults=50&q="+this.state.searchTerms))
.then(function(response) {
response.data.items.map(function(el){
if (el.id.kind === "youtube#video"){

var newYoutubeItem = {
source: 'youtube',
data: {
id: el.id.videoId,
thumbnail: el.snippet.thumbnails.medium.url,
title: el.snippet.title,
length: "Unknown",
streamUrl: "",
streamUrlLoading: false
}
};

Axios.get(_this.prepareUrl("https://www.googleapis.com/youtube/v3/videos?part=id,snippet,contentDetails&id="+newYoutubeItem.data.id))
.then(function(response){
newYoutubeItem.data.length = _this.ytDurationToStr(response.data.items[0].contentDetails.duration);
tempList.push(newYoutubeItem);

_this.songListChangeCallback(tempList);
_this.setState({songList: tempList});
});
}

var newYoutubeItem = {
source: 'youtube',
data: {
id: el.id.videoId,
thumbnail: el.snippet.thumbnails.medium.url,
title: el.snippet.title,
length: "Unknown",
streamUrl: "",
streamUrlLoading: false
}
};

Axios.get(_this.prepareUrl("https://www.googleapis.com/youtube/v3/videos?part=id,snippet,contentDetails&id="+newYoutubeItem.data.id))
.then(function(response){
newYoutubeItem.data.length = _this.ytDurationToStr(response.data.items[0].contentDetails.duration);
searchResults.push(newYoutubeItem);

_this.songListChangeCallback(searchResults);
_this.setState({songList: searchResults});
});
});
});
}

if (searchSources.indexOf('youtube playlists') >= 0) {
Axios.get(this.prepareUrl("https://www.googleapis.com/youtube/v3/search?part=id,snippet&type=playlist&maxResults=50&q="+this.state.searchTerms))
.then(function(response) {
response.data.items.map(function(el){

console.log(response);
var newYoutubePlaylistItem = {
source: 'youtube playlists',
data: {
id: el.id.playlistId,
thumbnail: el.snippet.thumbnails.medium.url,
title: el.snippet.title,
length: "N/A",
}
};
searchResults.push(newYoutubePlaylistItem);

});

_this.songListChangeCallback(searchResults);
_this.setState({songList: searchResults});
});
}
}



}

togglePlay(){
Expand Down
1 change: 1 addition & 0 deletions app/components/SearchField.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default class SearchField extends Component {
this.state = {
allowableSources: [
{ value: 'youtube' },
{ value: 'youtube playlists' },
{ value: 'bandcamp' },
{ value: 'soundcloud' },
{ value: 'vimeo' },
Expand Down
16 changes: 8 additions & 8 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "electron-react-boilerplate",
"productName": "electron-react-boilerplate",
"version": "1.0.0",
"description": "Electron application boilerplate based on React, React Router, Webpack, React Hot Loader for rapid application development",
"name": "nuclear",
"productName": "nuclear",
"version": "0.1.0",
"description": " An Electron-based, multiplatform music player app that streams from multiple sources ",
"main": "./main.js",
"author": {
"name": "C. T. Lin",
"email": "chentsulin@gmail.com",
"url": "https://github.com/chentsulin"
"name": "nukeop",
"email": "alsw@protonmail.com",
"url": "https://github.com/nukeop/"
},
"license": "MIT",
"license": "GPL-3.0",
"dependencies": {
}
}

0 comments on commit e974093

Please sign in to comment.