• 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7
  • 9
Virtual Python Folders
#61
I just updated the script because the actual videos didn't show up.
http://max-server.informatik.uni-bremen....m/joox.rar
Reply
#62
I just found a quite funny tweak:
You can speed the whole python folder stuff up by quazillion percent if you start the following very advanced script before browsing your shiny new virtual folders:

Code:
import time
while(1):
    time.sleep(500)
so..we should probably keep python running while browsing the new folders.
Reply
#63
Yes, python startup can take a while, so we should really have something to keep it hanging around during browsing - usually DLLs only unload after 30 seconds delay, but I think python unloads immediately. It's certainly something that we need to look into.

I prefer the progress dialog idea rather than a heartbeat - you want the user to be able to cancel at anytime, which should be doable:

Instead of the single WaitForSingleEvent, we can have a short one (or just sleep() waiting on a bool) and after (say) 2 seconds we can throw the progress dialog up. The AddItem() routine can be used to update the display (either by saying "10 items loaded", or by passing another param into it if python knows how far along it is) and/or we can have another routine to update the progress if necessary.

The user can then cancel immediately, whereby we kill the script.

As for configurability, if we add a context menu set of items (eg via calling the script with a "contextmenu" parameter, and/or the path to the item) then that can be done. Obviously another function to action the menu would be required as well.

In addition, we could have XML configuration (handled entirely from XBMC) though that would mean the scripts would need to parse the XML configuration themselves.

Obviously you guys are the ones that are writing scripts though, not me, so feel free to rubbish my ideas and come up with better things Smile

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#64
Just keep in mind sys.argv is shared between python sessions.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#65
Nuka1195 Wrote:Just keep in mind sys.argv is shared between python sessions.
so what do you think? is there any other possibility to tell each individual instance "who called"?

another note on the plugin browse dialog: is there a possibility to default the share name to the folder name instead of default.py?
Reply
#66
I don't know if it will be an issue, just reminding people of that.

I mentioned about the browse dialog. I think if it's changed to browse for folder, since it already adds default.py, that might fix it.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#67
Nuka, what's up with the iconPath bug? Does that still exist? I saw that jmarshall changed a line in the code. Did that fix it four you? Because I'm still getting no icons.

Btw: Is it a known bug that sometimes XBMC recognizes movies correctly via autoscan and shows IMDB info and even a cover to download, but doesn't use that cover, even if you manually select it? This happened to me with all recent versions of XBMC. Maybe those two are related somehow...
Reply
#68
Yes JMarshalls version of XBMC_PC shows Icons. Works well.

Edit: I should point out when I said freezes trying to play the trailer, I meant on the PC.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#69
JMarshall, I saw your TODO: about sending a Listitem to addItem. I had a play at it, but screwed something up, the lost my changes and got fed upSmile

Would you have created the CFileItem in the python method setDirectoryItem() and passed that or pass the Listitem to addItem() and create the CFileItem there?
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#70
I would get it working with GUIListItem first using the already setup stuff for creating them, and pass that in.

Once that was working, change the python stuff from GUIListItem to CFileItem.

Then expand the listitem creation with a method to set the tag info and we're done.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#71
Ok, I'm posting the diff file for all to see my failed attempt.

I get the "could not connect to network server." error dialog.

log
Quote:20:05:32 M: 41222144 DEBUG: CGUIMediaWindow::GetDirectory (plugin://video/Apple Movie Trailers Plugin/default.py/)
20:05:32 M: 41222144 DEBUG: ParentPath = []
20:05:32 M: 41226240 DEBUG: DIRECTORY::CPluginDirectory::GetDirectory - opened with plugin://video/Apple Movie Trailers Plugin/default.py/
20:05:32 M: 41226240 DEBUG: DIRECTORY::CPluginDirectory::GetDirectory - doing arguments stuff...
20:05:32 M: 41226240 DEBUG: DIRECTORY::CPluginDirectory::getNewHandle - getHandle called.
20:05:32 M: 41226240 DEBUG: DIRECTORY::CPluginDirectory::getNewHandle - Handle #:0
20:05:32 M: 41226240 DEBUG: DIRECTORY::CPluginDirectory::getNewHandle - AddressBig Grin00A16D4
20:05:32 M: 41226240 DEBUG: DIRECTORY::CPluginDirectory::GetDirectory - calling script Q:\plugins\video\Apple Movie Trailers Plugin\default.py('plugin://video/Apple Movie Trailers Plugin/default.py/','0','')
20:05:32 M: 41226240 DEBUG: LoadLibraryA('python24.dll')
20:05:32 M: 40103936 DEBUG: LoadLibrary('python24.dll') returning: 0xa4da50
20:05:33 M: 40103936 DEBUG: dllGetProcAddress(0x6d0780(kernel32.dll), 'InterlockedCompareExchange') => 0x1fde34
20:05:33 M: 39837696 DEBUG: GetModuleFileNameA(0x0, 0x1e102490, 256) => 'xbmc.xbe'
20:05:33 M: 39837696 DEBUG: advapi32.dll fake function RegQueryInfoKeyA called
20:05:33 M: 39837696 DEBUG: advapi32.dll fake function RegQueryInfoKeyA called
20:05:33 M: 39780352 DEBUG: LoadLibraryExA called with flags:
- LOAD_WITH_ALTERED_SEARCH_PATH
20:05:33 M: 39780352 DEBUG: LoadLibraryA('zlib.pyd')
20:05:33 M: 39710720 DEBUG: kernel32.dll fake function DisableThreadLibraryCalls called
20:05:33 M: 39710720 DEBUG: LoadLibrary('zlib.pyd') returning: 0xa3f160
20:05:33 M: 39710720 DEBUG: dllGetProcAddress(0x1e1b0000(zlib.pyd), 'initzlib') => 0x1e1b2150
20:05:33 M: 38830080 INFO: -->Python Initialized<--
20:05:33 M: 38830080 INFO:
20:05:33 M: 38301696 DEBUG: DIRECTORY::CPluginDirectory::GetDirectory - waiting...
20:05:33 M: 38301696 DEBUG: kernel32.dll fake function SetConsoleCtrlHandler called
20:05:33 M: 38301696 DEBUG: LoadLibraryExA called with flags:
- LOAD_WITH_ALTERED_SEARCH_PATH
20:05:33 M: 38301696 DEBUG: LoadLibraryA('_sqlite.pyd')
20:05:33 M: 38014976 DEBUG: kernel32.dll fake function DisableThreadLibraryCalls called
20:05:33 M: 38014976 DEBUG: LoadLibrary('_sqlite.pyd') returning: 0x84dc30
20:05:33 M: 38014976 DEBUG: dllGetProcAddress(0x10000000(_sqlite.pyd), 'init_sqlite') => 0x100012b0
20:05:33 M: 24645632 ERROR: CThread:ConfusedtaticThread : Access violation at 0x0001c0b5: Reading location 0x00000000
20:05:34 M: 24539136 INFO: Loading skin file: DialogBusy.xml
20:05:35 M: 24399872 ERROR: Unable to wait for NTP reply from the SNTP server, GetLastError returns 10060
20:05:43 M: 24465408 DEBUG: DIRECTORY::CPluginDirectory::GetDirectory - wait timed out
20:05:43 M: 24465408 DEBUG: DIRECTORY::CPluginDirectory::removeHandle - RemoveHandle called with handle 0.
20:05:43 M: 24465408 ERROR: CGUIMediaWindow::GetDirectory(plugin://video/Apple Movie Trailers Plugin/default.py/) failed
20:05:43 M: 24465408 DEBUG: CGUIMediaWindow::GetDirectory ()
20:05:43 M: 24465408 DEBUG: ParentPath = []
20:05:43 M: 24465408 DEBUG: CURL::CURL - Url has no protocol .tbn, empty CURL created
20:05:43 M: 24465408 DEBUG: CURL::CURL - Url has no protocol \folder.jpg, empty CURL created
20:05:43 M: 24465408 DEBUG: CURL::CURL - Url has no protocol add, empty CURL created
20:05:43 M: 23941120 INFO: Loading skin file: DialogOK.xml
20:05:45 M: 24006656 DEBUG: CApplication::OnKey: 256 pressed, action is 7

diff file:
Code:
Index: xbmc/FileSystem/PluginDirectory.cpp
===================================================================
--- xbmc/FileSystem/PluginDirectory.cpp (revision 9957)
+++ xbmc/FileSystem/PluginDirectory.cpp (working copy)
@@ -55,7 +55,7 @@
}

// TODO: This should really pass in a CGUIListItem that we create directly from the ListItem sent in.
-void CPluginDirectory::AddItem(int handle, const string &name, const string &url, const string &iconPath, bool isDirectory)
+void CPluginDirectory::AddItem(int handle, const string &url, CGUIListItem &item, bool bIsFolder)
{
   if (handle < 0 || handle >= (int)globalHandles.size())
   {
@@ -63,11 +63,14 @@
     return;
   }
   CPluginDirectory *dir = globalHandles[handle];
-  CFileItem *pItem = new CFileItem(name);
+  CFileItem *pItem = new CFileItem(item.GetLabel());
   pItem->m_strPath = url;
-  pItem->SetThumbnailImage(iconPath);
-  pItem->m_bIsFolder = isDirectory;
-  pItem->SetLabelPreformated(true); // TODO: This is probably better not set once we have all the CFileItem stuff available.
+  pItem->SetLabel(item.GetLabel());
+  pItem->SetLabel2(item.GetLabel2());
+  pItem->SetIconImage(item.GetIconImage());
+  pItem->SetThumbnailImage(item.GetThumbnailImage());
+  pItem->m_bIsFolder = bIsFolder;
+  //pItem->SetLabelPreformated(true); // TODO: This is probably better not set once we have all the CFileItem stuff available.
   dir->m_listItems.Add(pItem);
}

Index: xbmc/FileSystem/PluginDirectory.h
===================================================================
--- xbmc/FileSystem/PluginDirectory.h (revision 9957)
+++ xbmc/FileSystem/PluginDirectory.h (working copy)
@@ -20,7 +20,7 @@
   bool GetPluginsDirectory(const CStdString &type, CFileItemList &items);

   // callbacks from python
-  static void AddItem(int handle, const string &name, const string &url, const string &iconPath, bool isDirectory);
+  static void AddItem(int handle, const string &url, CGUIListItem &item, bool bIsFolder);
   static void EndOfDirectory(int handle);
private:
   static vector<CPluginDirectory*> globalHandles;
Index: xbmc/lib/libPython/xbmcmodule/xbmcmodule.cpp
===================================================================
--- xbmc/lib/libPython/xbmcmodule/xbmcmodule.cpp (revision 9957)
+++ xbmc/lib/libPython/xbmcmodule/xbmcmodule.cpp (working copy)
@@ -18,6 +18,7 @@
// include for constants
#include "pyutil.h"
#include "../../../PlayListPlayer.h"
+#include "listitem.h"

using namespace XFILE;

@@ -36,49 +37,49 @@
  * start of xbmc methods
  *****************************************************************/
   PyDoc_STRVAR(setDirectoryEntry__doc__,
-    "setDirectoryEntry(pointer,name,url,isDirectory [,iconpath]) -- Callback function to pass directory contents back to XBMC.\n"
+    "setDirectoryEntry(handle, url, listitem, [,isFolder]) -- Callback function to pass directory contents back to XBMC.\n"
     "\n"
-    "handle:      longint, handle the virtualpythonfolder plugin was started with.\n"
-    "name:        name of the playlist entry\n"
-    "url:         url of the playlist entry. would be python:// for another virtual directory\n"
-    "isDirectory: 0 if it is no directory, <>0 if it is.\n"
-    "iconpath:    (optional) path to the icon to be displayed in xbmc\n");
+    "handle      : Integer - handle the plugin was started with.\n"
+    "url         : string - url of the entry. would be plugin:// for another virtual directory\n"
+    "listitem    : ListItem - item to add.\n"
+    "isFolder    : [opt] bool - True=folder / False=not a folder(default).\n"
+    "\n"
+    "example:\n"
+    "  - xbmc.setDirectoryEntry(handle, 'F:\\\\Trailers\\\\300.mov', listitem)\n");

   PyObject* XBMC_setDirectoryEntry(PyTypeObject *type, PyObject *args, PyObject *kwds)
   {
-    static char *keywords[] = {"handle", "name", "url", "isDirectory", "iconpath", NULL };
-    string name;
-    string url;
-    string iconpath;
-    PyObject *pName = NULL;
+    static char *keywords[] = {"handle", "url", "listitem", "isFolder", NULL };
+    int handle = -1;
     PyObject *pURL = NULL;
-    PyObject *pIconPath = NULL;
-    int isDirectory=0;
-    int handle;
+    PyObject *pItem = NULL;
+    bool bIsFolder = false;
     // parse arguments
     if (!PyArg_ParseTupleAndKeywords(
       args,
       kwds,
-      "iOOi|O",
+      "iOO|b",
       keywords,
       &handle,
-      &pName,
       &pURL,
-      &isDirectory,
-      &pIconPath
+      &pItem,
+      &bIsFolder
       ))
     {
       return NULL;
     };

-    if (!PyGetUnicodeString(name, pName, 1)) return NULL;
-    if (!PyGetUnicodeString(url, pURL, 1)) return NULL;
-    if (pIconPath && !PyGetUnicodeString(iconpath, pIconPath, 1)) return NULL;
+    string url;
+    if (!PyGetUnicodeString(url, pURL, 1) || !ListItem_CheckExact(pItem)) return NULL;
+    
+    ListItem *pListItem = NULL;
+    pListItem = (ListItem *)pItem;
+    Py_INCREF(pListItem);

     // call the directory class to add our item
-    DIRECTORY::CPluginDirectory::AddItem(handle, name, url, iconpath, isDirectory != 0);
+    DIRECTORY::CPluginDirectory::AddItem(handle, url, (CGUIListItem &)pListItem, bIsFolder);

-    Py_INCREF(Py_None);
+    //Py_INCREF(Py_None);
     return Py_None;
   }
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#72
Ah - I think the error is in the cast from ListItem * to (CGUIListItem &) - this is not correct.

I believe you want pListItem->item, which will give a CGUIListItem *. Cast this to a CFileItem * and pass it straight in should do the trick. That way later on we can change the item member of ListItem to be a CFileItem * and add the set infotag stuff.

I'm not sure where python cleans up it's listitem memory, so you either want to copy the CFileItem object in AddItem(), or use it directly (if python isn't going to clean it up).

You can copy the object just from CFileItem *newItem = new CFileItem(*item);

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#73
Smile

I don't want to sound smarter than I am, but originally I was trying to pass CFileItem, but screwed something up and lost my changes.

I used your copy method instead of accessing it directly. I'll commit this and you can clean it up. Smile

Thanks

Edit: Label2 isn't being set, i'll play with that for a little bit.

Edit2: It was that I commented out the
pItem->SetLabelPreformated(true); line

Edit3: committed. A new AMT script http://xbmc-scripting.googlecode.com/svn...Plugin.zip This one filters out empty trailer urls, so if you use the minimal database, only newest will show anything.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#74
Now that we have access to label2, is there anyway the sort by button can be set to sort on the copntents of label2?

I know I'm getting ahead of myself, just didn't want to forget.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#75
What's nice about this plugin feature. AMT trailers play fine when the GUI and videoplayer are in 1080i. No memory issues.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
  • 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7
  • 9

Logout Mark Read Team Forum Stats Members Help
Virtual Python Folders0