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

feature request: Pass original filename to media player when streaming torrent #99

Closed
2 of 3 tasks
TnTora opened this issue Jul 9, 2024 · 0 comments
Closed
2 of 3 tasks
Labels
Milestone

Comments

@TnTora
Copy link

TnTora commented Jul 9, 2024

Checklist

  • I checked that this feature has not been requested before
  • I checked that this feature is not in the "Not planned" list
  • This feature will benefit the majority of users

Problem Description / Use Case

With the current torrentstream implementation, the player uses "stream" as a the default filename. Having the actual filename available to the player (mostly mpv) would allow the use of custom mpv scripts that rely on it as well as some basic mpv features such as naming screenshots based on filename.

Proposed Solution

Not sure how correct this is (it's my first time using go) but it seems to work with mpv, not sure about the other players.

Registering "/stream/" instead of "/stream" in newServerManager

http.HandleFunc("/stream", ret.serve) to http.HandleFunc("/stream/", ret.serve)

and then inserting the current torrent filename in GetStreamingUrl

func (c *Client) GetStreamingUrl() string {
	if c.torrentClient.IsAbsent() {
		return ""
	}

	settings := c.repository.settings.MustGet()
	if settings.StreamingServerHost == "0.0.0.0" {
		return fmt.Sprintf("http://127.0.0.1:%d/stream", settings.StreamingServerPort)
	}
	return fmt.Sprintf("http://%s:%d/stream", settings.StreamingServerHost, settings.StreamingServerPort)
}

to

func (c *Client) GetStreamingUrl() string {
	if c.torrentClient.IsAbsent() || c.currentFile.IsAbsent() {
		return ""
	}

	settings := c.repository.settings.MustGet()
	if settings.StreamingServerHost == "0.0.0.0" {
		return fmt.Sprintf("http://127.0.0.1:%d/stream/%s", settings.StreamingServerPort, url.PathEscape(c.currentFile.MustGet().DisplayPath()))
	}
	return fmt.Sprintf("http://%s:%d/stream/%s", settings.StreamingServerHost, settings.StreamingServerPort, url.PathEscape(c.currentFile.MustGet().DisplayPath()))
}
@TnTora TnTora added the feature request New feature or request label Jul 9, 2024
5rahim added a commit that referenced this issue Jul 9, 2024
5rahim added a commit that referenced this issue Jul 11, 2024
@5rahim 5rahim added this to the v2 milestone Aug 5, 2024
@5rahim 5rahim closed this as completed Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants