Jump to content

User Agent Override option for strm files


embybob1

Recommended Posts

embybob1

Hello Emby Team,

 

Related to an earlier feature request: https://emby.media/community/index.php?/topic/74731-additional-header-option-in-m3u-tuner-tv-source-setup-page/?hl=%2Buser+%2Bagent

 

I'm currently using .strm files to organize remote video content. My source requires me to send a specific HTTP_USER_AGENT in order to access the content. With IPTV sources it is possible to set a custom User Agent in order to use when playing IPTV content, however such an option does not exist for remote video content using .strm files.

 

My suggestion would be to make it possible to add a custom User Agent either within the .strm file (as an optional parameter/line within the file), or possibly set this at the Library level. Adding it in the .strm file seems most logical IMHO since multiple .strm files from different sources could be in the same library.

 

Alternatively, for me it would be enough to be able to set/override the User Agent for all remote content going through Emby HttpClient / ffmpeg //ffprobe etc. As a temporary solution I already tried to create wrapper scripts around the ffmpeg binaries to supply/override the User Agent using the user-agent parameter, however unfortunately Emby itself also seems to access the stream URL directly (in case or Direct Play?), so no way for me to hook into that.

 

Here is an extract of the logs when trying to access remote content using the Emby Android App:

 

 

2019-12-16 12:43:14.876 Info HttpClient: GET http://some.remote.location/video.mkv
2019-12-16 12:43:14.901 Error HttpServer: Error processing request
    *** Error Report ***
    Version: 4.3.0.30
    Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_amd64.deb
    Operating system: Unix 5.3.0.24
    64-Bit OS: True
    64-Bit Process: True
    User Interactive: True
    Runtime: file:///opt/emby-server/system/System.Private.CoreLib.dll
    Processor count: 2
    Program data path: /var/lib/emby
    Application directory: /opt/emby-server/system
    MediaBrowser.Model.Net.HttpException: MediaBrowser.Model.Net.HttpException: Unauthorized
       at Emby.Server.Implementations.HttpClientManager.CoreHttpClientManager.SendAsyncInternal(HttpRequestOptions options, String httpMethod)
       at Emby.Server.Implementations.HttpClientManager.CoreHttpClientManager.SendAsync(HttpRequestOptions options, String httpMethod)
       at Emby.Server.Implementations.HttpServer.HttpResultFactory.GetContent(StaticFileResultOptions options, Int64 offset, Int64 length, CancellationToken cancellationToken)
       at Emby.Server.Implementations.HttpServer.FileWriter.SetContentResponseHeaders(Nullable`1 reportedTotalContentLength, CancellationToken cancellationToken)
       at Emby.Server.Implementations.HttpServer.HttpResultFactory.GetStaticResult(IRequest requestContext, StaticResultOptions options)
       at Emby.Server.MediaEncoding.Api.Progressive.BaseProgressiveStreamingService.ProcessRequest(StreamRequest request, Boolean isHeadRequest)
       at Emby.Server.Implementations.Services.ServiceController.GetTaskResult(Task task)
       at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, RestPath restPath, String responseContentType, CancellationToken cancellationToken)
       at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, ReadOnlyMemory`1 urlString, ReadOnlyMemory`1 localPath, CancellationToken cancellationToken)
    Source: Emby.Server.Implementations
    TargetSite: Void MoveNext()
    
2019-12-16 12:43:14.902 Info HttpServer: HTTP Response 500 to *. Time: 30ms. http://emby:8096/videos/645686/stream.mkv...

 

Checking tcpdump to see the request that went out, there was no User-Agent sent at all:

 

 

GET /video.mkv HTTP/1.1
Accept-Encoding: deflate
Host: some.remote.location

 

Thanks for your consideration.

 

Bob

Edited by embybob1
  • Thanks 1
Link to comment
Share on other sites

  • 5 months later...
redmi18
On 12/16/2019 at 8:40 PM, Luke said:

Hi, yes I agree this would make sense. Thanks.

can i change user agent of ffprobe in emby now?

Link to comment
Share on other sites

  • 1 year later...
Josephus
On 12/16/2019 at 11:40 PM, Luke said:

Hi, yes I agree this would make sense. Thanks.

Any progress on it now? Also Referrer in Headers.

Link to comment
Share on other sites

39 minutes ago, Josephus said:

Any progress on it now? Also Referrer in Headers.

Hi, not yet, sorry.

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...