Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow serving of interactive CSVs directly to Handy #3756

Merged

Conversation

hontheinternet
Copy link
Contributor

Description

This PR allows the interactive videos to directly serve the funscript files (in the CSV format) directly to Handy.
This is possible when Handy is on the same WiFi network as the stash server, or when the stash server is hosted on the internet.
This decreases the reliance on the TheHandy funscript hosting server and makes for a faster initial setup of loading the interactive script.

  • Added the following endpoint to serve CSV of funscript directly to Handy
    • /<id>/interactive_csv
    • For now, I bypassed the authentication for this just this API endpoint. Maybe a better way is to use the API key as a query parameter.
  • Added a setting use-stash-hosted-funscript which toggles between
    1. the original way of uploading the funscript file to TheHandy server to get a temporary CSV format URL
    2. the new way of just using the newly added endpoint as the CSV format URL
  • Another thing to note is that I convert the funscript file to CSV and save it in the same folder as the Funscript (since the Handy needs it in a CSV format), lazily (meaning the CSV file is generated on first request) and use the CSV file it if it exists.
    • Maybe we could change it to save it in the cache folder, but it worked fine for me.

I did run the formatting and linting commands before making the PR.

Please ignore the previous PR, there was an issue with GitHub. Just created another PR.
First time submitting a PR here, let me know if there any issues, and hope that it gets merged. :)

@DogmaDragon DogmaDragon added improvement Something needed tweaking. backend Pull requests that update Go code javascript Pull requests that update Javascript code labels May 23, 2023
@kermieisinthehouse
Copy link
Collaborator

Thank you for contributing!

I've reviewed the code and it looks good, but as you mentioned, passing an API key is preferable to hole-punching the authentication. You can probably add something to scene.go in urlbuilders to accomplish this, see GetStreamURL in that file for an example of how another feature does this.

@WithoutPants
Copy link
Collaborator

Is there any benefit to using the Handy server at all? I'm wondering if we shouldn't just shift to directly uploading only and not bother with a separate setting.

I don't think converting and saving in the source file's directory is a good idea. Assuming that the conversion process isn't too intensive, I think we can probably convert on the fly in the direct funscript URL handler. We can look at caching it as a separate change later on if needed.

@hontheinternet
Copy link
Contributor Author

hontheinternet commented May 31, 2023

Is there any benefit to using the Handy server at all? I'm wondering if we shouldn't just shift to directly uploading only and not bother with a separate setting.

Currently, we provide the URL of the Stash server to Handy so that Handy can try to access the CSV file directly.
Suppose, we open the Stash server using http://localhost:9999, then the URL sent to Handy is localhost, and if we want to send the correct accessible URL of Stash, Stash has to determine, among the different interface IPs, stash is hosted on, which URL/domain to use.

For a general user, the default option of uploading to Handy might be easier and seamless, whereas in an opt-in feature, stash can allow direct serving to the Handy given the Stash server is accessible from Handy.

I don't think converting and saving in the source file's directory is a good idea. Assuming that the conversion process isn't too intensive, I think we can probably convert on the fly in the direct funscript URL handler. We can look at caching it as a separate change later on if needed.

Yeah, I was also not every inclined to adding files to the source directories. I just did it because it seemed easy with simple caching. I can benchmark the latency of converting Funscript to CSV for various sizes and if it is less than a few hundred milliseconds even for a large funscript, then I think on the fly is good enough.

@WithoutPants WithoutPants added this to the Version 0.22.0 milestone Jun 2, 2023
@hontheinternet
Copy link
Contributor Author

Cleaned up the commits (previously there were 2 copies of the same commits) and rebased to the latest develop branch.
Also, removed the hole in the authentication and now it uses the API key as query parameter to let the handy access the csv hosted by Stash in case of an authenticated server.

I guess the main thing left to do, is to not create a CSV in the source folder but somewhere in the cache folder or maybe on the fly. I'll try to make it on-the-fly conversion for now.

@hontheinternet
Copy link
Contributor Author

Made the Funscript to CSV conversion on the fly, and on my PC (CPU: 5600X) it takes much less a second.
Let me know if there are any more changes needed. @WithoutPants

@WithoutPants WithoutPants merged commit 4f0e0e1 into stashapp:develop Jul 11, 2023
2 checks passed
randemgame added a commit to randemgame/stash that referenced this pull request Jul 12, 2023
commit 67d4f97
Author: WithoutPants <[email protected]>
Date:   Wed Jul 12 11:51:52 2023 +1000

    Multiple scene URLs (stashapp#3852)

    * Add URLs scene relationship
    * Update unit tests
    * Update scene edit and details pages
    * Update scrapers to use urls
    * Post-process scenes during query scrape
    * Update UI for URLs
    * Change urls label

commit 76a4bfa
Author: chickenwingavalanche <[email protected]>
Date:   Tue Jul 11 19:25:24 2023 -0600

    Add keyboard shortcut to toggle video looping in scene player (stashapp#3902)

    * Use shift+L to toggle video looping in scene player

commit 3e810cf
Author: WithoutPants <[email protected]>
Date:   Wed Jul 12 10:53:46 2023 +1000

    Add nil checks in identify (stashapp#3905)

commit c1352f9
Author: NodudeWasTaken <[email protected]>
Date:   Wed Jul 12 02:45:33 2023 +0200

    Safari video height css fix (stashapp#3882)

commit f665aa8
Author: WithoutPants <[email protected]>
Date:   Wed Jul 12 10:38:52 2023 +1000

    Update make target in Dockerfile-CUDA

commit b2b52bc
Author: chickenwingavalanche <[email protected]>
Date:   Tue Jul 11 18:37:46 2023 -0600

    Add missing scene player shortcuts to Help -> Keyboard Shortcuts (stashapp#3903)

    Co-authored-by: chickenwingavalanche <[email protected]>

commit 96f2229
Author: DingDongSoLong4 <[email protected]>
Date:   Wed Jul 12 02:05:35 2023 +0200

    Improve Makefile (stashapp#3901)

    * Improve Makefile
    * Make ui targets consistent
    ---------
    Co-authored-by: WithoutPants <[email protected]>

commit 278a064
Author: WithoutPants <[email protected]>
Date:   Tue Jul 11 19:16:22 2023 +1000

    Revert "Add AirPlay and Chromecast support (stashapp#2872)" (stashapp#3898)

    This reverts commit 8e235a2.

commit 0c0ba19
Author: Csaba Maulis <[email protected]>
Date:   Tue Jul 11 13:54:42 2023 +0800

    Add `-v/--version` flag to print version string (stashapp#3883)

    * Add `-v/--version` flag to print version string

    - Created a new flag `-v/--version` in the command-line interface to display the version number and exit.
    - Moved all version-related functions inside the config package to the new file `manager/config/version.go` to avoid circular dependencies.
    - Added a new `GetVersionString()` function to generate a formatted version string.
    - Updated references to the moved version functions.
    - Updated references in the `Makefile`.

    * Move version embeds to build package

    * Remove githash var

    ---------

    Co-authored-by: WithoutPants <[email protected]>

commit 969af2a
Author: A Ghoul Coder <[email protected]>
Date:   Tue Jul 11 07:53:53 2023 +0200

    add phasher (stashapp#3864)

    * add phasher

    A simple `phasher` program that accepts a video file as a command line
    argument and calculates and prints its PHASH.

    The goal of this separate executable is to have a simple way to
    calculate phashes that doesn't depend on a full stash instance so that
    third-party systems and tools can independently generate PHASHes which
    can be used for interacting with stash and stash-box APIs and data.

    Currently `phasher` is built in the default make target along with
    `stash` by simply running `make`.
    Cross-platform targets have not been considered.

    Concurrency is intentionally not implemented because it is simpler to
    use [GNU Parallel](https://www.gnu.org/software/parallel/).
    For example:
    ```
    parallel phasher {} ::: *.mp4
    ```

    * standard dir structure for phasher and separate make target

    The make target still needs to be integrated into the rest of the
    Makefile so it can be built as part of normal releases.

    * phasher: basic usage output and quiet option
    * phasher: allow and process multiple command line arguments
    * phasher: camelCase identifiers
    * phasher: initialize ffmpeg and ffprobe only once

commit cbdd4d3
Author: Flashy78 <[email protected]>
Date:   Mon Jul 10 21:37:00 2023 -0700

    Identify: Options to skip multiple results and single name performers (stashapp#3707)

    Co-authored-by: WithoutPants <[email protected]>

commit ff22577
Author: hontheinternet <[email protected]>
Date:   Tue Jul 11 13:32:42 2023 +0900

    Add additional stats to the Stats page (stashapp#3812)

    * Add o_counter, play_duration, play_count, unique_play_count stats

commit 4f0e0e1
Author: hontheinternet <[email protected]>
Date:   Tue Jul 11 13:02:09 2023 +0900

    Allow serving of interactive CSVs directly to Handy (stashapp#3756)

    * allow direct serve interactive CSVs to Handy
    ---------
    Co-authored-by: kermieisinthehouse <[email protected]>

commit 8e235a2
Author: CJ <[email protected]>
Date:   Mon Jul 10 22:47:11 2023 -0500

    Add AirPlay and Chromecast support (stashapp#2872)

    * dynamically load cast_sender.js
    * add https://www.gstatic.com to connectableOrigins
    * Add toggle for chromecast

commit c499c20
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Jul 11 13:40:29 2023 +1000

    Bump semver from 5.7.1 to 5.7.2 in /ui/v2.5 (stashapp#3896)

    Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
    - [Release notes](https://github.com/npm/node-semver/releases)
    - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
    - [Commits](npm/node-semver@v5.7.1...v5.7.2)

    ---
    updated-dependencies:
    - dependency-name: semver
      dependency-type: indirect
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit f0d901a
Author: plato178 <[email protected]>
Date:   Tue Jul 11 03:45:20 2023 +0100

    Add codec filters (stashapp#3843)

    * Add video_codec and audio_codec filter criteria
    * Add Audio Codec and Video Codec UI filters

commit 93b41fb
Author: WithoutPants <[email protected]>
Date:   Tue Jul 11 11:53:49 2023 +1000

    Add folder rename detection (stashapp#3817)

commit 5c38836
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Jul 11 11:40:49 2023 +1000

    Bump stylelint from 15.1.0 to 15.10.1 in /ui/v2.5 (stashapp#3889)

    Bumps [stylelint](https://github.com/stylelint/stylelint) from 15.1.0 to 15.10.1.
    - [Release notes](https://github.com/stylelint/stylelint/releases)
    - [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
    - [Commits](stylelint/stylelint@15.1.0...15.10.1)

    ---
    updated-dependencies:
    - dependency-name: stylelint
      dependency-type: direct:development
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit cec9195
Author: DingDongSoLong4 <[email protected]>
Date:   Tue Jul 11 03:40:20 2023 +0200

    Fix scene missing flicker on scene page (stashapp#3857)

    * use useLayoutEffect
    * Remove unnecessary nullability in ScenePlayer

commit 0268565
Author: DingDongSoLong4 <[email protected]>
Date:   Tue Jul 11 03:36:57 2023 +0200

    Makefile cleanup (stashapp#3876)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Pull requests that update Go code improvement Something needed tweaking. javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants