# Plex Plug-in Kickstarter

**URL:** <https://forums.plex.tv/t/plex-plug-in-kickstarter/30490>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [March 11, 2013, 1:30am UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490 "2013-03-11T01:30:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianscrivener](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/brianscrivener/32/5568_2.png) [@brianscrivener](https://forums.plex.tv/u/brianscrivener)\
**Post date:** [March 11, 2013, 1:30am UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490/1 "2013-03-11T01:30:29Z")

</div>

Not sure if i am in the right place for this post, first of all i am quite new to Plex forums and i just bought a Plex pass to get all the neat new features :)&nbsp;which&nbsp;are great buy the way awsome work

my problem is im trying to make myself a few simple Youtube plugins from the&nbsp;Plex Plug-in Kickstarter page in Dev tools and with no luck i cant get them to show up on the server or work!! :( can someone maybe help me with this? i think its maybe some code within the app "\_\_init\_\_" file but cant understand the problem.. i will post the code below along with the feed i am trying to set up along with username from Youtube if that helps many thanks for helping guys&nbsp; :D

&nbsp;

Youtube Channel:&nbsp;[http://www.youtube.com/user/BFvsGF](http://www.youtube.com/user/BFvsGF)

&nbsp;

Youtube Name:&nbsp;BFvsGF

&nbsp;

Code:

&nbsp;

```
from datetime import datetime
import time
import re

####################################################################################################

PLUGIN\_PREFIX = “\<?= $VARS['prefix']; ?\>”

FEED = ‘\<?= $VARS['feed']; ?\>’  
YOUTUBE\_VIDEO\_PAGE = ‘[http://www.youtube.com/watch?v=%s](http://www.youtube.com/watch?v=%25s)’  
YOUTUBE\_VIDEO\_FORMATS = [‘Standard’, ‘Medium’, ‘High’, ‘720p’, ‘1080p’]  
YOUTUBE\_FMT = [34, 18, 35, 22, 37]

NAME = L(‘Title’)

# make sure to replace artwork with what you want

ART = ‘art-default.jpg’  
ICON = ‘icon-default.png’

####################################################################################################

def Start():  
Plugin.AddPrefixHandler(PLUGIN\_PREFIX, Menu, NAME, ICON, ART)  
Plugin.AddViewGroup(“InfoList”, viewMode=“InfoList”, mediaType=“items”)  
Plugin.AddViewGroup(“List”, viewMode=“List”, mediaType=“items”)  
MediaContainer.art = R(ART)  
MediaContainer.title1 = NAME  
DirectoryItem.thumb = R(ICON)  
VideoItem.thumb = R(ICON)

```
HTTP.CacheTime = CACHE_1HOUR

```

def Menu():

```
dir = MediaContainer(viewGroup="InfoList",title2=L('Episodes'), httpCookies=HTTP.GetCookiesForURL('http://www.youtube.com/'))
dir = FeedMenu(feed = FEED)
return dir

```

def FeedMenu(feed=’’):  
dir = MediaContainer(viewGroup=“InfoList”,title2=L(‘Episodes’), httpCookies=HTTP.GetCookiesForURL(‘[http://www.youtube.com/](http://www.youtube.com/)’))

```
if '?' in feed:
  feed = feed + '&alt=json'
else:
  feed = feed + '?alt=json'

rawfeed = JSON.ObjectFromURL(feed, encoding='utf-8',cacheTime=CACHE_1HOUR)
if rawfeed['feed'].has_key('entry'):
  for video in rawfeed['feed']['entry']:
    if video.has_key('yt$videoid'):
      video_id = video['yt$videoid']['$t']
    elif video['media$group'].has_key('media$player'):
      try:
        video_page = video['media$group']['media$player'][0]['url']
      except:
        video_page = video['media$group']['media$player']['url']
      video_id = re.search('v=([^&]+)', video_page).group(1)
    else:
      video_id = None      
    title = video['title']['$t']

    if (video_id != None) and not(video.has_key('app$control')):
      try:
	    published = Datetime.ParseDate(video['published']['$t']).strftime('%a %b %d, %Y')
      except: 
  	    published = Datetime.ParseDate(video['updated']['$t']).strftime('%a %b %d, %Y')
      if video.has_key('content') and video['content'].has_key('$t'):
	    summary = video['content']['$t']
      else:
	    summary = video['media$group']['media$description']['$t']
      duration = int(video['media$group']['yt$duration']['seconds']) * 1000
      try:
	    rating = float(video['gd$rating']['average']) * 2
      except:
	    rating = 0
      thumb = video['media$group']['media$thumbnail'][0]['url']
      dir.Append(Function(VideoItem(PlayVideo, title=title, subtitle=published, summary=summary, duration=duration, rating=rating, thumb=Function(Thumb, url=thumb)), video_id=video_id))

if len(dir) == 0:
  return MessageContainer(L('Error'), L('This query did not return any result'))
else:
  return dir

```

def Thumb(url):  
try:  
data = HTTP.Request(url, cacheTime=CACHE\_1WEEK).content  
return DataObject(data, ‘image/jpeg’)  
except:  
return Redirect(R(ICON))

def PlayVideo(sender, video\_id):  
yt\_page = HTTP.Request(YOUTUBE\_VIDEO\_PAGE % (video\_id), cacheTime=1).content

fmt\_url\_map = re.findall(’“url\_encoded\_fmt\_stream\_map”.+?"([^"]+)’, yt\_page)[0]  
fmt\_url\_map = fmt\_url\_map.replace(’/’, ‘/’).split(’,’)

fmts =   
fmts\_info = {}

for f in fmt\_url\_map:  
map = {}  
params = f.split(’\u0026’)  
for p in params:  
(name, value) = p.split(’=’)  
map[name] = value  
quality = str(map[‘itag’])  
fmts\_info[quality] = String.Unquote(map[‘url’])  
fmts.append(quality)

index = YOUTUBE\_VIDEO\_FORMATS.index(Prefs[‘youtube\_fmt’])  
if YOUTUBE\_FMT[index] in fmts:  
fmt = YOUTUBE\_FMT[index]  
else:  
for i in reversed( range(0, index+1) ):  
if str(YOUTUBE\_FMT\*) in fmts:  
fmt = YOUTUBE\_FMT\*  
break  
else:  
fmt = 5

url = (fmts\_info[str(fmt)]).decode(‘unicode\_escape’)  
Log(" VIDEO URL --\> " + url)  
return Redirect(url)
```

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![brianscrivener](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/brianscrivener/32/5568_2.png) [@brianscrivener](https://forums.plex.tv/u/brianscrivener)\
**Post date:** [March 11, 2013, 1:59am UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490/2 "2013-03-11T01:59:38Z")

</div>

Ps I am also using the latest version of pms for plex home theatre and server if that helps at all?

Sent from my iPhone using Tapatalk

---

<div class="post-metadata">

**Author:** ![Gerk](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/gerk/32/81980_2.png) [@Gerk](https://forums.plex.tv/u/Gerk)\
**Post date:** [March 11, 2013, 3:28pm UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490/3 "2013-03-11T15:28:18Z")

</div>

A couple of things to note ... the kickstarter is pretty out of date from what I can tell, so might not be the best starting place. &nbsp;I'd try starting by looking at other working plugins.

Also things like this are not going to work (they are PHP) &nbsp;

```
<?= $VARS['prefix']; ?>
```

---

<div class="post-metadata">

**Author:** ![brianscrivener](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/brianscrivener/32/5568_2.png) [@brianscrivener](https://forums.plex.tv/u/brianscrivener)\
**Post date:** [March 11, 2013, 3:30pm UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490/4 "2013-03-11T15:30:48Z")

</div>

Ok thank you I will give it a try with a working plugin thank you.

Sent from my iPhone 5 using Tapatalk

---

<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:** [March 11, 2013, 5:37pm UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490/5 "2013-03-11T17:37:16Z")

</div>

Hello Brian!

Based on a YouTube channel template I created a while back to quickly build some YouTube based channels I could quickly create a _BFvsGF_ channel. I've attached it to this post.

The basic template code can be seen/forked/downloaded from here if you lke: [https://github.com/sander1/basic-yt-user-channel.bundle](https://github.com/sander1/basic-yt-user-channel.bundle)

---

<div class="post-metadata">

**Author:** ![brianscrivener](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/brianscrivener/32/5568_2.png) [@brianscrivener](https://forums.plex.tv/u/brianscrivener)\
**Post date:** [March 11, 2013, 6:02pm UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490/6 "2013-03-11T18:02:37Z")

</div>

Thank you ill give it a try now 🙂

Sent from my iPhone 5 using Tapatalk

---

<div class="post-metadata">

**Author:** ![brianscrivener](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/brianscrivener/32/5568_2.png) [@brianscrivener](https://forums.plex.tv/u/brianscrivener)\
**Post date:** [March 12, 2013, 12:03am UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490/7 "2013-03-12T00:03:15Z")

</div>

Well would like to say thanks for the help guys I finally did it app works flawless on my tv made up some graphics to to with the prank channel on YouTube have a look

 ![post-121003-13630465911477.jpg](https://global.discourse-cdn.com/plex/original/3X/8/1/81c25475f0170fdb5c10ae5b4150f366f0d0c6e9.jpg)

Sent from my iPhone 5 using Tapatalk

---

<div class="post-metadata">

**Author:** ![Gerk](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/gerk/32/81980_2.png) [@Gerk](https://forums.plex.tv/u/Gerk)\
**Post date:** [March 12, 2013, 12:13pm UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490/8 "2013-03-12T12:13:34Z")

</div>

Awesome, glad it worked out for you ;)

---

<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, 11:01pm UTC](https://forums.plex.tv/t/plex-plug-in-kickstarter/30490/9 "2019-12-20T23:01:39Z")

</div>

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