Skip to content

Commit

Permalink
fix the 404 error
Browse files Browse the repository at this point in the history
  • Loading branch information
philpw99 committed Jan 5, 2024
1 parent dfa858a commit 092ecf0
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 6 deletions.
92 changes: 92 additions & 0 deletions Modification List.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
Modification List:
=============
api/routes_scene.go

func Routes()
r.Route("/{sceneId}", func(r chi.Router) {
// Added
r.Get("/stream/org/*", rs.StreamOrgDirect)

}

// Added:
func (rs sceneRoutes) StreamOrgDirect(w http.ResponseWriter, r *http.Request) {
scene := r.Context().Value(sceneKey).(*models.Scene)
// check if it's funscript
aStr := strings.Split(r.RequestURI, ".")
if strings.ToLower(aStr[len(aStr)-1]) == "funscript" {
// it's a funscript request
rs.Funscript(w, r)
return
}

// return 404 if the scene does not have file
// Primary file method no longer works, only Files.List()[0].Path
Path := scene.Files.List()[0].Path
if Path == "" {
w.WriteHeader(http.StatusNotFound)
return
}
http.ServeFile(w, r, Path)
}

===========
ui/v2.5/src/components/Scenes/SceneDetails/ExternalPlayerButton.tsx

export const ExternalPlayerButton: React.FC<IExternalPlayerButtonProps> = ({
scene,
}) => {

const intl = useIntl();


const alwaysShow = true; // Added

const { paths } = scene;
const { files } = scene; // added
const { path } = files[0]; // added.

if (!paths || !paths.stream || (!isAndroid && !isAppleDevice && !alwaysShow))
// moded
return <span />;


if (isAndroid) {
const scheme = streamURL.protocol.slice(0, -1);
streamURL.hash = `Intent;action=android.intent.action.VIEW;scheme=${scheme};type=video/mp4;S.title=${encodeURI(
title
)};end`;
streamURL.protocol = "intent";
url = streamURL.toString();
} else if (isAppleDevice) {
streamURL.host = "x-callback-url";
streamURL.port = "";
streamURL.pathname = "stream";
streamURL.search = `url=${encodeURIComponent(stream)}`;
streamURL.protocol = "vlc-x-callback";
url = streamURL.toString();
} else if (alwaysShow) {
// In all other cases.

url = stream + "/org/" + encodeURIComponent(file.toString()); // like http://192.168.1.10:9999/scene/123/stream/org/file.mp4
url2 = url; // for now. Need to fix it for PlayA
streamURL.pathname = "/api/playa/v1/video/" + scene.id;
}

return (
<Button
className="minimal px-0 px-sm-2 pt-2"
variant="secondary"
title={intl.formatMessage({ id: "actions.open_in_external_player" })}
>
<a href={url2}>
PlayA&nbsp;&nbsp;
<Icon icon={faExternalLinkAlt} color="white" />
</a>&nbsp;&nbsp;
<a href={url}>
DeoVR&nbsp;&nbsp;
<Icon icon={faExternalLinkAlt} color="white" />
</a>&nbsp;&nbsp;
</Button>
);
};
9 changes: 5 additions & 4 deletions internal/api/routes_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ func (rs sceneRoutes) StreamOrgDirect(w http.ResponseWriter, r *http.Request) {
return
}

// return 404 if the scene does not have primary file
filePath := scene.Files.Primary()
if filePath == nil {
// return 404 if the scene does not have file
// Primary file method no longer works, only Files.List()[0].Path
Path := scene.Files.List()[0].Path
if Path == "" {
w.WriteHeader(http.StatusNotFound)
return
}
http.ServeFile(w, r, filePath.Path)
http.ServeFile(w, r, Path)
}

func (rs sceneRoutes) StreamDirect(w http.ResponseWriter, r *http.Request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ export const ExternalPlayerButton: React.FC<IExternalPlayerButtonProps> = ({
<a href={url2}>
PlayA&nbsp;&nbsp;
<Icon icon={faExternalLinkAlt} color="white" />
</a>
</a>&nbsp;&nbsp;
<a href={url}>
DeoVR&nbsp;&nbsp;
<Icon icon={faExternalLinkAlt} color="white" />
</a>
</a>&nbsp;&nbsp;
</Button>
);
};
Expand Down

0 comments on commit 092ecf0

Please sign in to comment.