Skip to content

Commit

Permalink
Fixed a bug and increased compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzahi12345 committed Jan 21, 2018
1 parent 2a80ea9 commit 43399be
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
10 changes: 6 additions & 4 deletions backend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ app.post('/mp4fileexists', function(req, res) {
});

app.get('/video/:id', function(req , res){
var head;
const path = "video/" + req.params.id + ".mp4";
const stat = fs.statSync(path)
const fileSize = stat.size
Expand All @@ -223,7 +224,7 @@ app.get('/video/:id', function(req , res){
: fileSize-1
const chunksize = (end-start)+1
const file = fs.createReadStream(path, {start, end})
const head = {
head = {
'Content-Range': `bytes ${start}-${end}/${fileSize}`,
'Accept-Ranges': 'bytes',
'Content-Length': chunksize,
Expand All @@ -232,7 +233,7 @@ app.get('/video/:id', function(req , res){
res.writeHead(206, head);
file.pipe(res);
} else {
const head = {
head = {
'Content-Length': fileSize,
'Content-Type': 'video/mp4',
}
Expand All @@ -242,6 +243,7 @@ app.get('/video/:id', function(req , res){
});

app.get('/audio/:id', function(req , res){
var head;
const path = "audio/" + req.params.id + ".mp3";
const stat = fs.statSync(path)
const fileSize = stat.size
Expand All @@ -254,7 +256,7 @@ app.get('/audio/:id', function(req , res){
: fileSize-1
const chunksize = (end-start)+1
const file = fs.createReadStream(path, {start, end})
const head = {
head = {
'Content-Range': `bytes ${start}-${end}/${fileSize}`,
'Accept-Ranges': 'bytes',
'Content-Length': chunksize,
Expand All @@ -263,7 +265,7 @@ app.get('/audio/:id', function(req , res){
res.writeHead(206, head);
file.pipe(res);
} else {
const head = {
head = {
'Content-Length': fileSize,
'Content-Type': 'audio/mp3',
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export class AppComponent {
this.postsService.path = backendUrl;
this.postsService.startPath = backendUrl;
this.postsService.startPathSSL = backendUrl;
},
error => {
console.log(error);
});
}

Expand Down
1 change: 1 addition & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { PostsService } from 'app/posts.services';
import {APP_BASE_HREF} from '@angular/common';

@NgModule({
declarations: [
Expand Down
6 changes: 2 additions & 4 deletions src/app/posts.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ export class PostsService {
}

loadNavItems() {
return this.http.get("../../backend/config/default.json")
console.log("Config location: " + window.location.href + "backend/config/default.json");
return this.http.get(window.location.href + "backend/config/default.json")
.map(res => res.json());
//This is optional, you can remove the last line
// if you don't want to log loaded json in
// console.
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>YoutubeDLMaterial</title>
<base href="/">
<base href="./">

<meta name="viewport" content="width=device-width, initial-scale=1">

Expand All @@ -12,7 +12,6 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://unpkg.com/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet"> <script src="systemjs.config.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

</head>
<body>
<app-root></app-root>
Expand Down

0 comments on commit 43399be

Please sign in to comment.