# Best Practices

**URL:** <https://forums.plex.tv/t/best-practices/119731>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [October 22, 2015, 10:41am UTC](https://forums.plex.tv/t/best-practices/119731 "2015-10-22T10:41:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_revo2](https://avatars.discourse-cdn.com/v4/letter/_/54ee81/32.png) [@\_revo2](https://forums.plex.tv/u/_revo2)\
**Post date:** [October 22, 2015, 10:41am UTC](https://forums.plex.tv/t/best-practices/119731/1 "2015-10-22T10:41:43Z")

</div>

Hi,  
The Documentation is insufficient and I didn’t find some good examples.

1. What’s the best practice to pass a Cookie to the Url Service?
2. Exists there any more documentation about the framework besides the ones linked here in the Sticky?
3. Is ‘Cookie = GetCookiesForURL(url)’ possible? Or do I have to go down the road to manually deconstruct a returned response header? I find it extremely irritating to use the build in functions the whole time and when there’s one case where the documentation lacks information I end up having to import urllib and requests to get one piece of logic done. I really need the cookie to retrieve the video url.
4. Can the URL Service Access the Data API feeded with Data from the main Plugin?
5. Can a global Search Service return a directory object?

It would be extremely helpful, if someone experienced could answer my questions.

---

<div class="post-metadata">

**Author:** ![coryo123](https://avatars.discourse-cdn.com/v4/letter/c/a587f6/32.png) [@coryo123](https://forums.plex.tv/u/coryo123)\
**Post date:** [October 22, 2015, 8:49pm UTC](https://forums.plex.tv/t/best-practices/119731/2 "2015-10-22T20:49:51Z")

</div>

1-I don’t think you can pass anything to the url service besides the url. Some channels like YouTubeTV create custom urls for the urlservice which can include extra data. like `http://something.that.doesnt.exist/?foo=bar&cookie=stuff`

You could try skipping using a url service entirely.

if you do something like this in channel code I think its pretty much the equivalent of using `url=` on an object.

```
oc.add(VideoClipObject(
        key = Callback(MetadataObjectForURL, url=url, cookie="TEST"),
        rating_key = url,
        items = MediaObjectsForURL(url=url, cookie="TEST")
))

```

then you can define `MetadataObjectForURL` and `MediaObjectsForURL` in your channel code and pass them anything you want.

2-The only documentation I’ve found is the PlexPlug-inFramework.pdf and the undocumented stuff in the google docs sticky.

3-`HTTP.CookiesForURL(url)` should get you the cookie data. I needed a value from a cookie once so I did

```
r = HTTP.Request(url=LOGIN_URL, headers=headers, values=payload)

pattern = Regex('hash=([^;]*)')
hash = pattern.search(HTTP.CookiesForURL(LOGIN_URL)).group(1)
Dict['hash'] = hash
Dict.Save()

```

4-I don’t think the URL Service can access anything from the channel (Dict, Data, Prefs, etc)

5-I don’t know about global search, I’ve just been putting a Search(query) function in my channel code and using an InputDirectoryObject to call it. I think global search would have stricter requirements on what you return.

---

<div class="post-metadata">

**Author:** ![\_revo2](https://avatars.discourse-cdn.com/v4/letter/_/54ee81/32.png) [@\_revo2](https://forums.plex.tv/u/_revo2)\
**Post date:** [October 24, 2015, 3:52pm UTC](https://forums.plex.tv/t/best-practices/119731/3 "2015-10-24T15:52:34Z")

</div>

Thanks for your response.

First I went with encoding the cookie and appending him to the url passed to the service where I stripped the encoded cookie and decoded him again.

It was a pain in the ass, so I stripped the the URL Service entireley!

Thanks for your answer.

---

<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:** [January 8, 2020, 7:52pm UTC](https://forums.plex.tv/t/best-practices/119731/4 "2020-01-08T19:52:23Z")

</div>


