plugin tutorial?

I searched, I swear!
I am not completely new to coding, but python is a tricky beast sometimes.

there are so many different ways to use the containers, and call outs that every technique isnt the same across the board.

sooo, im trying to figure out these plugins. i read a sudo manual thread where the writer said "its NOT rocket science..... coding apps is really easy"

but then goes on to NOT explain anything other than the coding phrases. I would like to know how they interact, why they are used, and how to manipulate them.

certain tags, and phrases have to be written together. thats not stated in the manual thread.

so, anyone have a good, semi tutorial where i can see how things interact and reverse engineer it. i have tried to look at apps already out, but they arent clear to me whats going on and where.

if you havent already, take a look at the official framework docs here: http://dev.plexapp.com/docs/

Also, the best thing that worked for me was looking at the other codes. The main jist of all the webvideo apps is that they try to find the urls from the page source that have a video automatically playing. Once you have that, the rest is easy. Take a look at the ones I did. They are fairly straight forawrd. I think only the USA one uses regex coding. The rest is all plex framework 1.



i have looked at the Docs, the wiki. and other apps guys.

i still cant seem to figure out where to put feed locations? i might still be not understanding how plex is working. but as of right now, the apps i have looked at ( daily show ) arent very clear as to what they are doing.

i will check yours hrcolb0 when i get home and back on my mac

i want clarification as to what the files do.

the .py file has what? the details of the scraping? or the details on the video?
the site config, that is just for flash and silverlight sites that you CANT find the feed?
.joen files? uhhh what? i have looked at them, but they are not similar between different apps so its hard to find the common path.

thats what im trying to figure out.

thanks for the help, just trying to get a grasp of it.



Feel free to ask any questions. I was in your shoes only like a month or two ago.

As Billy said the Framework docs should help answer most of your questions.

You can also d/l as a PDF here: PlexMediaFramework



If you want to look at existing plugins for reference,

Try looking at the MTV Music Videos plugin…

That’s the one that helped me, and I think it helped hrcolb0 too.



The .py file: is the python script. It is used to parse(aka scrape) the site for content (ie.-video links, thumbnail links, titles)

the site config: is Best explained here!

a “.json” file: is Best described here!



Yes, if you can find and access the direct feed you would not need a site config.

See this link



Hope this helps!

Dbl_A

the python code (.py) is not just for parsing the site/finding the media, you also use it to create the plugin’s navigation/directory structure.



besides the site config (defines cropping and controls for flash players), the python code (/code/init.py normally) is where nearly all the action happens, the json and xml files are just for string/object storage (localization, default preferences, etc.), and the info.plist contains runtime environment settings. the python code is the main body of the plugin.

alright thanks guys this is starting to make more sense now.



sometimes its easier for me to listen to people explain it in their own words rather than read it. because sometimes things that are meant to be said arent typed.



I will check out the links you guys posted. thanks



( VBS.tv is the app i am working on, i have the navigation somewhat down. and have the app somewhat working in that respect. but no videos yet )



If you have a question about what a plugin is doing while you are looking at the code, you can use the Log() function to output to the plugin log in the /Library/Log/PMS Logs folder.

yeah i was going to use that too, im more interested in how the code is interacting with each other in the app itself.



The Framework functions are located in the PMS folder for that stuff.

ok i just sat here at pounded my head against the keyboard for about an hour



I butchered your NBC app ( well actually i fix the Full list menu. you had a capital V for video and it needs to be lower case )



but whatever. im starting to see how it all works. but i cant seem to figure out how its scraping the episodes



lets use NBC as an example



http://www.nbc.com/video/library/full-episodes/



thats the list page URL, both in the app and if you just plop it in your browser it loads a list of videos.

( if you go to the dailyshow app and look threw it its doing the same thing, and that url just shows a few videos, even though i know the app stores lots more than that )



i have tried multiple combinations of urls, and cant seem to get the right one to populate a list of the videos.



# PMS plugin framework<br />
from PMS import *<br />
from PMS.Objects import *<br />
from PMS.Shortcuts import *<br />
<br />
####################################################################################################<br />
<br />
VBS_PREFIX = "/video/vbs2"<br />
<br />
VBS_URL                     = "http://www.vbs.tv/"<br />
VBS_FULL_EPISODES_SHOW_LIST = "http://www.vbs.tv/shows/label/All/"<br />
VBS_IMAGE_THUMB_URL         = "http://assets.vbs.tv/%s_small.jpg"<br />
CACHE_INTERVAL              = 3600<br />
DEBUG                       = False<br />
ART           = 'art-default.png'<br />
ICON          = 'icon-default.png'<br />
<br />
####################################################################################################<br />
<br />
def Start():<br />
  Plugin.AddPrefixHandler(VBS_PREFIX, MainMenu, L("VBS"), VBS_IMAGE_THUMB_URL)<br />
  Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")<br />
<br />
####################################################################################################<br />
def MainMenu():<br />
    dir = MediaContainer(mediaType='video')<br />
    dir.Append(Function(DirectoryItem(all_shows, "Shows")))<br />
    return dir<br />
    <br />
####################################################################################################<br />
def all_shows(sender):<br />
    dir = MediaContainer(title2=sender.itemTitle)<br />
    dir.title1 = "VBS"<br />
    dir.title2 = "Shows"<br />
<br />
    content = XML.ElementFromURL(VBS_FULL_EPISODES_SHOW_LIST, True)<br />
    for item in content.xpath('//div[@class="item-list group-full-eps"]//div/ul/ul/li'):<br />
      titleUrl = item.xpath("a")[0].get('href')<br />
      image = item.xpath("a/img")[0].get('src')<br />
      title = item.xpath("a")[0].get('title')<br />
      Log(titleUrl)<br />
      dir.Append(Function(DirectoryItem(VideoPage, title), VBS_FULL_EPISODE_SHOW_LIST = titleUrl))<br />
    return dir <br />
<br />
  <br />
####################################################################################################<br />
def VideoPage(sender):<br />
    dir = MediaContainer(title2=sender.itemTitle)<br />
    content = XML.ElementFromURL(VBS_FULL_EPISODES_SHOW_LIST, True)<br />
    for item2 in content.xpath('//div[@class="group-list"]//ul/li'):<br />
        vidUrl = item2.xpath("a")[0].get('href')<br />
        if vidUrl.count("http://") == 0:<br />
          vidUrl=VBS_URL+vidUrl       <br />
        Log(vidUrl)<br />
        thumb2 = item2.xpath("a/img")[0].get('src')<br />
        title2 = item2.xpath("a")[0].get('title')<br />
        Log(title2)<br />
        dir.Append(WebVideoItem(vidUrl, title=title2, thumb=thumb2))<br />
    return dir



this is where im at right now, it loads up and get to the "shows" menu but nothing is populated.


I have also tried just using one shows URL, that has a list of episodes at the bottom of the page. similar to the daily show and nbc.

didnt work.

http://www.vbs.tv/watch/the-vice-guide-to-travel/the-vice-guide-to-liberia-1-of-8

so point me in the right direction guys. help me out. what is plex looking for when it generates the episode/ video list? how do we find it ( is it the RSS feeds? i have those firefoxp plugins, but i didnt think i needed to use it yet )?

i think i can get it working, if i just get a grip on where its getting its info from.

**** and yes there might be errant useless code in my stuff, im still trying to figure out what works together and what doesnt. i.e. the icon tags. couldnt get those to work ****

Are you checking the Logs?



FYI- you can run PMS in Terminal using:


~/Library/Application\ Support/Plex/Plex\ Media\ Server.app/Contents/MacOS/Plex\ Media\ Server


----------------------------------------------------------------------------------------------------------------------------------------------------------------------

I haven't gone through your code fully, but this jumps out:

dir.Append(Function(DirectoryItem(VideoPage, title), titleUrl = VBS_FULL_EPISODE_SHOW_LIST))]



1: You are trying to assign a variable ("titleUrl") with a global constant ("VBS_FULL_EPISODE_SHOW_LIST")
2: you haven't declared it as a argument with "VideoPage"
[size="2"]3: You don't need to pass global constants as arguments...[/size]


Without really looking, I might try:

      dir.Append(Function(DirectoryItem(VideoPage, title), titleUrl = titleUrl))<br />
    return dir <br />
<br />
  <br />
####################################################################################################<br />
def VideoPage(sender, titleUrl):<br />
    dir = MediaContainer(title2=sender.itemTitle)<br />
    content = XML.ElementFromURL(titleUrl, True)<br />
    for item2 in content.xpath('//div[@class="group-list"]//ul/li'):




Does this work? Better yet, does it make sense?
-Dbl_A

Just to expand on Dbl_A’s comments.



Conceptually it works by taking a URL, that could return html, rss, xml, json, and parsing the content at the end of that url to extract the metadata and URL to the video. How to actually do that metadata extraction depends on the format of the data. For xml xpath is generally used, as it is for html.



Let’s take you example:



<br />
content = XML.ElementFromURL(VBS_FULL_EPISODES_SHOW_LIST, True)<br />
    for item in content.xpath('//div[@class="item-list group-full-eps"]//div/ul/ul/li'):<br />
      titleUrl = item.xpath("a")[0].get('href')<br />
      image = item.xpath("a/img")[0].get('src')<br />
      title = item.xpath("a")[0].get('title')<br />
      Log(titleUrl)<br />
      dir.Append(Function(DirectoryItem(VideoPage, title), VBS_FULL_EPISODE_SHOW_LIST = titleUrl))<br />
    return dir <br />




The XML.ElementFromURL(VBS_FULL_EPISODES_SHOW_LIST, True) assumes the content at the end of VBS_FULL_EPISODES_SHOW_LIST is html, converts it to XML.

The for item in content.xpath('//div[@class="item-list group-full-eps"]//div/ul/ul/li'): uses xpath to iterate over the required elements in the XML document. I'm guessing this is your main issue since that xpath predicate is source specific, and it sounds like you just copied it from another plugin. View source on the html page helps here. You are looking for a list of elements that capture each video.

The statements like titleUrl = item.xpath("a")[0].get('href') are also xpath statements that extract individual pieces of metadata from within the XML elements extracted in the loop.

Jonny

Dbl_A - no i wasnt logging.



I will try those changes and see what happens thanks.



Johnny - thatnks I will check that out also



lets see if i can get this thing working

just for fun, this is what the log shows BEFORE i make any changes



Request: GET /video/vbs2<br />
<br />
Sent command: GET /video/vbs2<br />
User-Agent: Plex Firefox/2.0.0.11<br />
Host: localhost:32400<br />
Accept: */*<br />
Connection: keep-alive<br />
X-Plex-Language: en<br />
X-Plex-Version: 0.8.5-f4b13b5<br />
<br />
10:06:24.822494: com.plexapp.plugins.vbs2                :   (Framework) Loaded en strings<br />
10:06:24.822849: com.plexapp.plugins.vbs2                :   (Framework) Handling request :  /video/vbs2<br />
10:06:24.823100: com.plexapp.plugins.vbs2                :   (Framework) Response OK<br />
Reading 457 bytes in the body, code is 200<br />
Request: GET /video/vbs2/:/function/all_shows/KGRwMApTJ3NlbmRlcicKcDEKY2NvcHlfcmVnCl9yZWNvbnN0cnVjdG9yCnAyCihjUE1TLk9iamVjdHMKSXRlbUluZm9SZWNvcmQKcDMKY19fYnVpbHRpbl9fCm9iamVjdApwNApOdHA1ClJwNgooZHA3ClMnaXRlbVRpdGxlJwpwOApTJ1Nob3dzJwpwOQpzUyd0aXRsZTEnCnAxMApOc1MndGl0bGUyJwpwMTEKTnNTJ2FydCcKcDEyCk5zYnMu<br />
<br />
Sent command: GET /video/vbs2/:/function/all_shows/KGRwMApTJ3NlbmRlcicKcDEKY2NvcHlfcmVnCl9yZWNvbnN0cnVjdG9yCnAyCihjUE1TLk9iamVjdHMKSXRlbUluZm9SZWNvcmQKcDMKY19fYnVpbHRpbl9fCm9iamVjdApwNApOdHA1ClJwNgooZHA3ClMnaXRlbVRpdGxlJwpwOApTJ1Nob3dzJwpwOQpzUyd0aXRsZTEnCnAxMApOc1MndGl0bGUyJwpwMTEKTnNTJ2FydCcKcDEyCk5zYnMu<br />
User-Agent: Plex Firefox/2.0.0.11<br />
Host: localhost:32400<br />
Accept: */*<br />
Connection: keep-alive<br />
X-Plex-Language: en<br />
X-Plex-Version: 0.8.5-f4b13b5<br />
<br />
10:06:39.890904: com.plexapp.plugins.vbs2                :   (Framework) Handling request :  /video/vbs2/:/function/all_shows/KGRwMApTJ3NlbmRlcicKcDEKY2NvcHlfcmVnCl9yZWNvbnN0cnVjdG9yCnAyCihjUE1TLk9iamVjdHMKSXRlbUluZm9SZWNvcmQKcDMKY19fYnVpbHRpbl9fCm9iamVjdApwNApOdHA1ClJwNgooZHA3ClMnaXRlbVRpdGxlJwpwOApTJ1Nob3dzJwpwOQpzUyd0aXRsZTEnCnAxMApOc1MndGl0bGUyJwpwMTEKTnNTJ2FydCcKcDEyCk5zYnMu<br />
10:06:39.919552: com.plexapp.plugins.vbs2                :   (Framework) Calling named function 'all_shows'<br />
10:06:40.531536: com.plexapp.plugins.vbs2                :   (Framework) Received gzipped response from http://www.vbs.tv/shows/label/All/<br />
10:06:40.542682: com.plexapp.plugins.vbs2                :   (Framework) Response OK<br />
Reading 126 bytes in the body, code is 200<br />
10:06:45.533953: com.plexapp.plugins.vbs2                :   (Framework) Saved shared HTTP data<br />




as you both were right, when its trying to parse the "all show" data is gets that stupid gibberish

ok lets see if i can fix that

ok holy crap im finally getting a grasp



# PMS plugin framework<br />
from PMS import *<br />
from PMS.Objects import *<br />
from PMS.Shortcuts import *<br />
<br />
####################################################################################################<br />
<br />
VBS_PREFIX = "/video/vbs2"<br />
<br />
VBS_URL                     = "http://www.vbs.tv/"<br />
VBS_FULL_EPISODES_SHOW_LIST = "http://www.vbs.tv/shows/label/All/"<br />
VBS_IMAGE_THUMB_URL         = "http://assets.vbs.tv/%s_small.jpg"<br />
CACHE_INTERVAL              = 3600<br />
DEBUG                       = True<br />
ART           = 'art-default.png'<br />
ICON          = 'icon-default.png'<br />
<br />
####################################################################################################<br />
<br />
def Start():<br />
  Plugin.AddPrefixHandler(VBS_PREFIX, MainMenu, L("VBS"), VBS_IMAGE_THUMB_URL)<br />
  Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")<br />
<br />
####################################################################################################<br />
def MainMenu():<br />
    dir = MediaContainer(mediaType='video')<br />
    dir.Append(<br />
              Function(<br />
                       DirectoryItem(<br />
                         all_shows, "Shows",<br />
                         "",<br />
                         pageUrl = VBS_FULL_EPISODES_SHOW_LIST,<br />
                         summary="Browse Show List"<br />
                         )<br />
                   )<br />
              )<br />
    return dir<br />
    <br />
####################################################################################################<br />
def all_shows(sender, url=None):<br />
    dir = MediaContainer(title2=sender.itemTitle)<br />
    content = XML.ElementFromURL(pageUrl, True)<br />
    for item in content.xpath('//ul[@class="covers covers-wide"]//ul/h4'):<br />
      titleUrl = item.xpath("a")[0].get('href')<br />
      image = item.xpath("a/img")[0].get('src')<br />
      title = item.xpath("a")[0].get('title')<br />
      Log(titleUrl)<br />
      dir.Append(Function(DirectoryItem(VideoPage, title), pageUrl = titleUrl))<br />
    return dir <br />
<br />
  <br />
####################################################################################################<br />
def VideoPage(sender, titleUrl):<br />
    dir = MediaContainer(title2=sender.itemTitle)<br />
    content = XML.ElementFromURL(pageUrl, True)<br />
    for item2 in content.xpath('//div[@class="group-list"]//ul/li'):<br />
        vidUrl = item2.xpath("a")[0].get('href')<br />
        if vidUrl.count("http://") == 0:<br />
          vidUrl=VBS_URL+vidUrl       <br />
        Log(vidUrl)<br />
        thumb2 = item2.xpath("a/img")[0].get('src')<br />
        title2 = item2.xpath("a")[0].get('title')<br />
        Log(title2)<br />
        dir.Append(WebVideoItem(vidUrl, title=title2, thumb=thumb2))<br />
    return dir



so let me explain what im seeing here, and let me know if im right.

Def "all shows" ( still working on this part of the tag, as i get this error "TypeError: all_shows() takes exactly 2 non-keyword arguments (1 given)" )

but so the content.xpath and everything under that im finally getting.

this is what i was looking for clarification on, and when checking back and forth between 3 websites and 3 plugins. i think i figured it out.

so in the content.xpath for all shows, its saying

def all_shows(sender, url=None):still unsure of this tag
dir = MediaContainer(title2=sender.itemTitle) - still unsure of this tag "title2=sender.itemTitle"
content = XML.ElementFromURL(pageUrl, True) - still unsure of this tag "pageUrl, True" and what should be there. but i understand that pageUrl needs to be called. but its just calling the base URL for the show list
for item in content.xpath('//ul[@class="covers covers-wide"]//ul/h4'): - ok this is where i started to go "YEAH... thats IT!" so here the xpath is saying watch for a html class callout for "ul" with the name "cover cover-wide" which is the start of the show list. then it says once you found "
    the place for it to start looking for data. then look for "ul" then "h4" which has the title name and link ( but im not sure if it knows its a link at that point, but i think that doesnt matter as it will populate the link on its own )its telling the "python script to read and find those tags. then grab the info after it. not sure how to stop it though
    titleUrl = item.xpath("a")[0].get('href') - this is where it became more clear to me. this is stating the "titleUrl" will = the information that item.xpath grabbed starting at ("a")[0]not sure what that means .get means grab this part starting with ('href') of the code. or the Url for the video.... ok makes sense
    image = item.xpath("a/img")[0].get('src') - Then its saying, also grab the image, look for the code that starts with "a/img" meaning the line starts with a, but dont gran anything till you see img. then .get the image url..... makes sense
    title = item.xpath("a")[0].get('title') - then we see this one, might be a bit out of order i think. but you the get the title name, when xpath searches in that string again, for "a" the start of the line of code, then look threw the code till youy see "title" and then .get the title name.....makes sense
    Log(titleUrl) - still unsure of this tag, i know its logging the url, but not sure why, or if its necessary
    dir.Append(Function(DirectoryItem(VideoPage, title), pageUrl = titleUrl)) - still unsure of these tags, i know they are calling out and back to the other functions, but not sure why
    return dir


    just to explain I am still in the middle of coding, so some stuff is still like the NBC pluging/ Daily show plugin/ Justin.tv plugin. I am tayloring it to the VBS site now.

    but if im getting this right, the order that you tell xpath to search and grab the data is dependent on the structure of the page you are grabbing from.

    like below, its different that the NBC code.


<div class="item-list group-full-eps"> <br />
  				<div class="group-list" id="full_episodes"><br />
                        <ul>	<br />
    	        <br />
		<li><br />
		<a href="/friday-night-lights/video/the-lights-of-carroll-park/1237173/" title="The Lights of Carroll Park" class="img-wrap"><img src="http://video.nbc.com/nbcrewind2/thumb/946ac07a039c04f40089cc5e9defe741_large.jpg" alt="The Lights of Carroll Park" width="80" height="45" /></a><br />
		<p><strong><em>Friday Night Lights</em><br />The Lights of Carroll Park</strong></p><br />
<br />
	</li><br />




so you can see, the xpath saying, find "div class "item-list group-full-eps" which would be "
" then its saying, right after skip the other div tag. then you will see a ul tag, skip that, then you will see another ul tag ( which truthfully looks like a typo since there is NOT another ul tag in the html source ) and then start when you get to il. the end of the xpath statement start.


 <ul class="covers covers-wide"><br />
        <br />
	      <li id="show_poster_94"><br />
    <h4><a href="/watch/far-out--2">Far Out</a></h4><br />
<br />
    <h5><a href="/watch/far-out--2">Series</a></h5><br />




for reference from the VBS site html source

this is only for the First menu. the second show menu for episodes is similar ( as the posted one above ) but is different as the structure is slightly different on that page source

but I think im getting an idea of what this all means

<br />
Sent command: GET /video/vbs2<br />
User-Agent: Plex Firefox/2.0.0.11<br />
Host: localhost:32400<br />
Accept: */*<br />
Connection: keep-alive<br />
X-Plex-Language: en<br />
X-Plex-Version: 0.8.5-f4b13b5<br />
<br />
13:59:36.477518: com.plexapp.plugins.vbs2                :   (Framework) Loaded en strings<br />
13:59:36.477653: com.plexapp.plugins.vbs2                :   (Framework) Handling request :  /video/vbs2<br />
13:59:36.477863: com.plexapp.plugins.vbs2                :   (Framework) Response OK<br />
Reading 541 bytes in the body, code is 200<br />
Request: GET /video/vbs2/:/function/all_shows/KGRwMApTJ3NlbmRlcicKcDEKY2NvcHlfcmVnCl9yZWNvbnN0cnVjdG9yCnAyCihjUE1TLk9iamVjdHMKSXRlbUluZm9SZWNvcmQKcDMKY19fYnVpbHRpbl9fCm9iamVjdApwNApOdHA1ClJwNgooZHA3ClMnaXRlbVRpdGxlJwpwOApTJ1Nob3dzJwpwOQpzUyd0aXRsZTEnCnAxMApOc1MndGl0bGUyJwpwMTEKTnNTJ2FydCcKcDEyCk5zYnMu<br />
<br />
Sent command: GET /video/vbs2/:/function/all_shows/KGRwMApTJ3NlbmRlcicKcDEKY2NvcHlfcmVnCl9yZWNvbnN0cnVjdG9yCnAyCihjUE1TLk9iamVjdHMKSXRlbUluZm9SZWNvcmQKcDMKY19fYnVpbHRpbl9fCm9iamVjdApwNApOdHA1ClJwNgooZHA3ClMnaXRlbVRpdGxlJwpwOApTJ1Nob3dzJwpwOQpzUyd0aXRsZTEnCnAxMApOc1MndGl0bGUyJwpwMTEKTnNTJ2FydCcKcDEyCk5zYnMu<br />
User-Agent: Plex Firefox/2.0.0.11<br />
Host: localhost:32400<br />
Accept: */*<br />
Connection: keep-alive<br />
X-Plex-Language: en<br />
X-Plex-Version: 0.8.5-f4b13b5<br />
<br />
13:59:37.729837: com.plexapp.plugins.vbs2                :   (Framework) Handling request :  /video/vbs2/:/function/all_shows/KGRwMApTJ3NlbmRlcicKcDEKY2NvcHlfcmVnCl9yZWNvbnN0cnVjdG9yCnAyCihjUE1TLk9iamVjdHMKSXRlbUluZm9SZWNvcmQKcDMKY19fYnVpbHRpbl9fCm9iamVjdApwNApOdHA1ClJwNgooZHA3ClMnaXRlbVRpdGxlJwpwOApTJ1Nob3dzJwpwOQpzUyd0aXRsZTEnCnAxMApOc1MndGl0bGUyJwpwMTEKTnNTJ2FydCcKcDEyCk5zYnMu<br />
13:59:37.731361: com.plexapp.plugins.vbs2                :   (Framework) Calling named function 'all_shows'<br />
13:59:37.731626: com.plexapp.plugins.vbs2                :   (Framework) An exception happened:<br />
Traceback (most recent call last):<br />
  File "/Users/sethleelah/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/1/Python/PMS/Plugin.py", line 640, in __call<br />
    return function(*args, **kwargs)<br />
TypeError: all_shows() takes exactly 2 non-keyword arguments (1 given)<br />




this is where im stuck now, im about to punch my iMac in the screen.

the "all shows ()" media container, does not respond to ANYTHING

i tried to add a generic "values=None" still the same error. tried taking it all out. so it was empty. still same error ( 1 given ) but yet there is NONE!

i dont think im understanding the error

and just in case. this is the code that produced that error


####################################################################################################<br />
<br />
def Start():<br />
  Plugin.AddPrefixHandler(VBS_PREFIX, MainMenu, L("VBS"), VBS_IMAGE_THUMB_URL)<br />
  Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")<br />
<br />
####################################################################################################<br />
def MainMenu():<br />
    dir = MediaContainer(mediaType='video')<br />
    dir.Append(<br />
              Function(<br />
                       DirectoryItem(<br />
                         all_shows, "Shows",<br />
                         "",<br />
                         pageUrl = VBS_FULL_EPISODES_SHOW_LIST,<br />
                         summary="Browse Show List"<br />
                         )<br />
                   )<br />
              )<br />
    return dir<br />
    <br />
####################################################################################################<br />
def all_shows(sender, pageUrl):<br />
    dir = MediaContainer(title2=sender.itemTitle)<br />
    content = XML.ElementFromURL(pageUrl, True)<br />
    for item in content.xpath('//ul[@class="covers covers-wide"]//ul/h4'):<br />
      titleUrl = item.xpath("a")[0].get('href')<br />
      image = item.xpath("a/img")[0].get('src')<br />
      title = item.xpath("a")[0].get('title')<br />
      Log(titleUrl)<br />
      dir.Append(Function(DirectoryItem(VideoPage, title), pageUrl = titleUrl))<br />
    return dir <br />
<br />
  <br />
####################################################################################################<br />
def VideoPage(sender, titleUrl):<br />
    dir = MediaContainer(title2=sender.itemTitle)<br />
    content = XML.ElementFromURL(pageUrl, True)<br />
    for item2 in content.xpath('//div[@class="group-list"]//ul/li'):<br />
        vidUrl = item2.xpath("a")[0].get('href')<br />
        if vidUrl.count("http://") == 0:<br />
          vidUrl=VBS_URL+vidUrl       <br />
        Log(vidUrl)<br />
        thumb2 = item2.xpath("a/img")[0].get('src')<br />
        title2 = item2.xpath("a")[0].get('title')<br />
        Log(title2)<br />
        dir.Append(WebVideoItem(vidUrl, title=title2, thumb=thumb2))<br />
    return dir

A DirectoryItem accepts only a couple of standard arguments (see the dev docs). The arguments you’d like to pass to the next function need to be in the Function() statement. I hope the following example helps to make this clear. Note the remarks about the special sender argument.



<br />
def A_Function(sender):<br />
  dir = MediaContainer()<br />
<br />
  # Do some stuff to find, for example, the URL we need for a TV show episode<br />
  # ...<br />
  # ...<br />
  # ...<br />
  url = 'http://www.example.com/a_tv_show_episode.html'<br />
<br />
  dir.Append(Function(DirectoryItem(Another_Function, title='My Title'), url=url, my_var='Test'))<br />
  #                                 ^^^^^^^^^^^^^^^^                     ^^^^^^^^^^^^^^^^^^^^^^<br />
  #                                 This is the function                 These are the arguments passed<br />
  #                                 that is called when                  on to 'Another_Function'<br />
  #                                 this item is selected<br />
<br />
  return dir<br />
<br />
####################################################################################################<br />
<br />
def Another_Function(sender, url, my_var):<br />
  # Although you pass on 2 arguments to this function from 'A_Function' ('url' and 'my_var'), there<br />
  # is always the 'sender' argument, which (and I quote) "contains an ItemInfoRecord object,<br />
  # including information about the previous window state and the item that initiated the function<br />
  # call."<br />
  # You're free to use the info from the 'sender' argument, but you don't have to.<br />
  # 'sender.itemTitle' will contain the string "My Title" in this example.<br />
<br />
  Log(url)      # 'http://www.example.com/a_tv_show_episode.html'<br />
  Log(my_var)   # 'Test'<br />
<br />


********** i had this long reply written and firefox crashed



ARGHHH



so im not writing it again. but here



can we try to explain whats going on with my code? not some generic code? its hard to see where the flaws are when the code doesnt match really at all.



but i understand what your snippet meant. everything needs a matching pair. so if something is called, it needs to be received also.



well thatas where im confused. container 1 only sends the pageUrl to container 2



but yet its asking for a argument to be defined in the container for what?



so, looking at my code. where is the missing argument?



if i add summary to container two. it tells me i need 3 arguments instead of 2 now.

if i remove pageUrl, it askes for it to be defined.

if i remove sender, it asks for a definition



so this is why im confused, i cant add anything. or remove it to make it change. for the better.



i just dont see where to “add” another argument, everything seems to be linked as far as i can tell.



im about to hack off the 3rd container, because i just want to get the show list populated. so i can see that work and move on.

but it doesnt seem to be the problem, changing things in that container dont effect the error.