# changing the user agent

**URL:** <https://forums.plex.tv/t/changing-the-user-agent/3348>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [January 7, 2010, 4:45pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348 "2010-01-07T16:45:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Francesco](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/_francesco/32/82808_2.png) [@\_Francesco](https://forums.plex.tv/u/_Francesco)\
**Post date:** [January 7, 2010, 4:45pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/1 "2010-01-07T16:45:20Z")

</div>

hello, i’m trying to create a simple plugin that opens a predefined list of streams, one of these streams requires to access it with a different user-agent from plex default one.  
  
is there a way for me to change it from plugin code?  
  
  
  
Thank you very much in advance  
  
Francesco

---

<div class="post-metadata">

**Author:** ![koredom](https://avatars.discourse-cdn.com/v4/letter/k/8e8cbc/32.png) [@koredom](https://forums.plex.tv/u/koredom)\
**Post date:** [January 9, 2010, 6:16am UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/2 "2010-01-09T06:16:07Z")

</div>

> [@](#):
>
> hello, i'm trying to create a simple plugin that opens a predefined list of streams, one of these streams requires to access it with a different user-agent from plex default one.  
> is there a way for me to change it from plugin code?  
>   
> Thank you very much in advance  
> Francesco

  
yes would love to know if that works too

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [January 9, 2010, 7:41pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/3 "2010-01-09T19:41:57Z")

</div>

I think this is what you need:

```auto

def Start():<br />
  ...<br />
  ...<br />
  HTTP.SetHeader('User-agent', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5')<br />

```

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [January 9, 2010, 9:41pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/4 "2010-01-09T21:41:01Z")

</div>

I think you need a different approach. The code Sander posted would set the header for HTTP requests made from Python, but the way I read your post it seemed like you want to set the user agent when starting a stream from Plex. I’m not at home right now, and can’t remember exactly what the code is, but check the Apple Movie Trailers plug-in for an example (Apple doesn’t like you accessing the trailers from players that aren’t QuickTime, apparently).

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [January 9, 2010, 10:24pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/5 "2010-01-09T22:24:19Z")

</div>

Ah yes, you probably need this (MediaContainer.userAgent):

```auto

def Start():<br />
  ...<br />
  ...<br />
  MediaContainer.title1 = 'Apple Movie Trailers'<br />
  MediaContainer.content = 'Items'<br />
  MediaContainer.userAgent = 'Apple Mac OS X v10.6.1 CoreMedia v1.0.0.10B504'<br />
  MediaContainer.art = R('art-default.png')<br />
  HTTP.SetCacheTime(CACHE_INTERVAL)

```

---

<div class="post-metadata">

**Author:** ![koredom](https://avatars.discourse-cdn.com/v4/letter/k/8e8cbc/32.png) [@koredom](https://forums.plex.tv/u/koredom)\
**Post date:** [January 10, 2010, 5:22pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/6 "2010-01-10T17:22:37Z")

</div>

> [@](#):
>
> Ah yes, you probably need this (MediaContainer.userAgent):  
>   
> 
> ```auto
> 
> def Start():<br />
> ...<br />
> ...<br />
> MediaContainer.title1 = 'Apple Movie Trailers'<br />
> MediaContainer.content = 'Items'<br />
> MediaContainer.userAgent = 'Apple Mac OS X v10.6.1 CoreMedia v1.0.0.10B504'<br />
> MediaContainer.art = R('art-default.png')<br />
> HTTP.SetCacheTime(CACHE_INTERVAL)
> 
> ```

  
  
hmmm.... i need to send another user agent, when connecting to \*.mov streams, globally, if necessary. where can i change that?!  
  
thx

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [January 10, 2010, 6:20pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/7 "2010-01-10T18:20:25Z")

</div>

> [@](#):
>
> hmmm.... i need to send another user agent, when connecting to \*.mov streams, globally, if necessary. where can i change that?!  
>   
> thx

  
  
Hi!  
Exactly as I posted ;) MediaContainer.userAgent configures the user agent string for requests that the videoplayer does (opening/streaming video files)

---

<div class="post-metadata">

**Author:** ![koredom](https://avatars.discourse-cdn.com/v4/letter/k/8e8cbc/32.png) [@koredom](https://forums.plex.tv/u/koredom)\
**Post date:** [January 10, 2010, 7:55pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/8 "2010-01-10T19:55:59Z")

</div>

> [@](#):
>
> Hi!  
> Exactly as I posted ;) MediaContainer.userAgent configures the user agent string for requests that the videoplayer does (opening/streaming video files)

  
allright, do i have to work in the source and the recompile it? actually i'm not getting the point. sorry. very new to plex.

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [January 10, 2010, 10:06pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/9 "2010-01-10T22:06:56Z")

</div>

> [@](#):
>
> allright, do i have to work in the source and the recompile it? actually i'm not getting the point. sorry. very new to plex.

  
No - this is code for a media server plug-in, as detailed in the original post.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 8:35pm UTC](https://forums.plex.tv/t/changing-the-user-agent/3348/10 "2019-12-20T20:35:08Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
