Skip to content

Commit

Permalink
fix: safari hls support
Browse files Browse the repository at this point in the history
  • Loading branch information
alxarno committed Dec 3, 2024
1 parent 9593730 commit 9696d7d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion pkg/httputil/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package httputil
import (
"fmt"
"net/http"
"strings"

"github.com/alxarno/tinytune/pkg/index"
)
Expand Down Expand Up @@ -42,7 +43,7 @@ func (h *metaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

if len(r.PathValue("fileID")) != 0 {
meta, err := h.source.Pull(index.ID(r.PathValue("fileID")))
meta, err := h.source.Pull(index.ID(strings.ReplaceAll(r.PathValue("fileID"), ".m3u8", "")))
if err != nil {
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, "404")
Expand Down
4 changes: 2 additions & 2 deletions pkg/preview/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func TestPreviewImage(t *testing.T) {
{
Name: ".jpg",
SourcePath: "../../test/image.jpg",
DataLength: 3496,
DataLength: 3446,
Width: 1527,
Height: 898,
Hash: "0c8eaa3df6f838cbb5ece3ad12d1556fb781c2556dbe007c7b74b4e1df8c49f8",
Hash: "b9237e340eb886b5e437e4bc6fd19be612ff6653f3f733c3998ef20f320e6c20",
},
{
Name: ".gif",
Expand Down
2 changes: 1 addition & 1 deletion pkg/preview/preview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestPreview(t *testing.T) {
}{
{
source: mockSource{image: true, path: "../../test/image.jpg"},
dataHash: "0c8eaa3df6f838cbb5ece3ad12d1556fb781c2556dbe007c7b74b4e1df8c49f8",
dataHash: "b9237e340eb886b5e437e4bc6fd19be612ff6653f3f733c3998ef20f320e6c20",
},
{
source: mockSource{video: true, path: "../../test/sample.mp4"},
Expand Down
4 changes: 4 additions & 0 deletions web/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export const videoInit = (element) => {
if (src[0] == "#") {
src = src.substring(1)
}
if (src.includes("rts")){
src += ".m3u8/"
}

videoElement.innerHTML = `<source src="${src}" type="${origin.getAttribute("data-extension")}">`
wrapper.appendChild(videoElement)

Expand Down
4 changes: 2 additions & 2 deletions web/scss/_preview.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

.dir-list-item{
text-align: center;
margin-bottom: 2rem;
margin-bottom: 0;

> figcaption{
margin-top: 1rem;
Expand All @@ -27,7 +27,7 @@
--preview-width: min(var(--wrap-width), calc(var(--origin-width)* var(--wrap-height) / var(--origin-height)));

> .figure-img{
height: 100%;
height: inherit;
width: fit-content;
margin: auto;
}
Expand Down
2 changes: 1 addition & 1 deletion web/templates/item-video.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{define "video-item"}}<a href="/origin/{{ .ID }}" type="video" data-stream="{{ if streaming .Path }}/rts/{{.ID}}{{ else }}{{ end }}"class="image-lightbox" hx-boost="false" data-extension="{{ if streaming .Path }}application/x-mpegURL{{else}}video/{{ .Extension }}{{end}}" data-width="{{ .Resolution.Width }}" data-height="{{ .Resolution.Height }}"><figure class="figure dir-list-item">
{{define "video-item"}}<a href="/origin/{{ .ID }}" type="video" data-stream="{{ if streaming .Path }}/rts/{{.ID}}.m3u8{{ else }}{{ end }}"class="image-lightbox" hx-boost="false" data-extension="{{ if streaming .Path }}application/x-mpegURL{{else}}video/{{ .Extension }}{{end}}" data-width="{{ .Resolution.Width }}" data-height="{{ .Resolution.Height }}"><figure class="figure dir-list-item">
{{ if eq .Preview.Length 0 }}
{{ template "icon-video" .}}
{{ else }}
Expand Down

0 comments on commit 9696d7d

Please sign in to comment.