Skip to content

Commit

Permalink
show attribution + remove unnecesary demo code
Browse files Browse the repository at this point in the history
  • Loading branch information
ridhwaans committed Apr 13, 2019
1 parent 229f6a6 commit aec2cae
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 61 deletions.
8 changes: 7 additions & 1 deletion client/src/components/AlbumDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class AlbumDetail extends CellDetail {
let data = this.state.detailData
activeIndex = playlistIndex
scPlayer.play({ playlistIndex });

document.getElementById(style.spotifyPreviewUrl)
.innerHTML = data.tracks.items[activeIndex].external_urls.spotify
}

nextIndex() {
Expand Down Expand Up @@ -77,6 +80,9 @@ class AlbumDetail extends CellDetail {
}

activeIndex = 0
var demo = document.getElementById(style.spotifyPreviewUrl)
if (demo != null) demo.innerHTML = ''

scPlayer.playlist(data, function (track) {});
var MusicPlayer = WithSoundCloudAudio(props => {
return (
Expand Down Expand Up @@ -126,9 +132,9 @@ class AlbumDetail extends CellDetail {
</div>
<div id='CellDetail_right' className={style.cellDetailRight}>
<div id='CellDetail_close' className={style.cellDetailClose} onClick={this.closeCellDetail.bind(this)}>&#10006;</div>

<MusicPlayer soundCloudAudio={scPlayer}/>

<div id={style.spotifyPreviewUrl}/>
<div id={style.plWrap}>
<ul id={style.plList}>
{trackList}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/MovieDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MovieDetail extends CellDetail {
<div id='CellDetail_close' className={style.cellDetailClose} onClick={this.closeCellDetail.bind(this)}>&#10006;</div>
<div id='cellDetailPlayerDiv' className={style.cellDetailPlayerDiv}>
<video id='cellDetailPlayer' className={style.cellDetailPlayer} controls controlsList='nodownload'>
<source src={data.url_path} type='video/mp4'/>

</video>
</div>
<div id='CellDetailTitle' className={style.cellDetailTitle}> {title} </div>
Expand Down
8 changes: 6 additions & 2 deletions client/src/style/AlbumDetail.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
float: right;
position: relative;
overflow: auto;
background-color:transparent;
color:white;
background-color: transparent;
color: white;
}

.cell-detail-image {
Expand Down Expand Up @@ -81,6 +81,10 @@
color: var(--description-color);
}

#spotify-preview-url {
color: var(--title-color);
}

/* tracklist */
#plWrap {
margin:0 auto;
Expand Down
57 changes: 0 additions & 57 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,61 +40,4 @@ app.get('/api/tv/seasons/:id', function(req, res) {
res.json(season);
});

app.get('/music/:album_id/:disc_number/:track_number', function(req, res) {
var album = _.find(musicData.music, {id: req.params.album_id}); // Get albums
var track_fs_path = _.where(album.tracks.items, {disc_number: parseInt(req.params.disc_number), track_number: parseInt(req.params.track_number)}); // Get track
track_fs_path = String(_.pluck(track_fs_path, 'fs_path')); // Get track.fs_path

const path = track_fs_path
const stat = fs.statSync(path)
const head = {
'Content-Type': 'audio/mpeg',
'Content-Length': stat.size
}
res.writeHead(200, head);
fs.createReadStream(path).pipe(res);
});

app.get('/movies/:id', function(req, res) {
//var movie_fs_path = _.where(moviesData.movies, {id: parseInt(req.params.id)}); // Get movie
//movie_fs_path = String(_.pluck(movie_fs_path, 'fs_path')); // Get movie.fs_path
movie_fs_path = "./stock.mp4";
const path = movie_fs_path
const stat = fs.statSync(path)
const fileSize = stat.size
const range = req.headers.range
if (range) {
const parts = range.replace(/bytes=/, "").split("-")
const start = parseInt(parts[0], 10)
const end = parts[1]
? parseInt(parts[1], 10)
: fileSize-1
const chunksize = (end-start)+1
const file = fs.createReadStream(path, {start, end})
const head = {
'Content-Range': `bytes ${start}-${end}/${fileSize}`,
'Accept-Ranges': 'bytes',
'Content-Length': chunksize,
'Content-Type': 'video/mp4',
}
res.writeHead(206, head);
file.pipe(res);
} else {
const head = {
'Content-Length': fileSize,
'Content-Type': 'video/mp4',
}
res.writeHead(200, head)
fs.createReadStream(path).pipe(res)
}
});

console.log(figlet.textSync('homehost',
{
font: 'Larry 3D',
horizontalLayout: 'default',
verticalLayout: 'default'
}
));

app.listen(port, () => console.log(`Listening on port ${port}`));

0 comments on commit aec2cae

Please sign in to comment.