Help: How to get Label/Title from an item & send to Subtitles dialog?
#1
Hi

My basic question is how do I can get the label/title of the item that I stand on (No matter if it is inside an addon or regular kodi's window)

My purpose is :
- Stand and focus on an item (Inside addon, library, etc.)
- Press on a ket and open the subtitles dialog (When Kodi is not on Playing status!)
- Get the title/lable for using it for the "search" action in the subtitles addon.
* If it's a movie, so it will take the Movie's title and the year.
* If it's a tv-show, so it will take the Tv-show's name, Season number and Episode number

How do I get this title/lable?

Thanks.
Reply
#2
xbmc.getInfoLabel("ListItem.Title") is what you're looking for but what you're trying to accomplish isn't possible.
The subtitles dialog can only be opened while the player is running and it's an internal window so not controllable by an addon.

If you want to auto download subtitles, why not use an existing addon like autosubs ?
Reply
#3
Thanks.

Regarding the command I will check, where do I need to put it, in the subtitles addon or in kodi in the subtitles dialog?
Because I had a problem with that when I put this in the subtitles addon. When I used the "getInfoLabel" command it always took the control item from the Subtitles dialog on not from the window in the background.

Regarding the dialog, you can open the Subtitles dialog in every place by setting it in the keymap to open this dialog (I already did it)

The purpose is only to check if subtitles are exist in exteranl site (Through subtitles addon) without playing it.
With Manual Search it's working good, now I want it to automatic takes the title from the item that you focus on and use it for search automatic, instead of typing it manually.
Reply
#4
I believe the subtitle addon needs access to the playing file so you can't open it standalone but correct me if I'm wrong.
What you probably want is to create a contextmenu addon which grabs the infolabels of the selected item and sends that to the subtitle addon or create your own subtitle scraper.
If you call the getInfoLabel in the subtitle addon it's already too late, you need it before that.

If you have no python experience that will be very hard to create as a first project ;-)

Take a look at existing contextmenu addons, most probably they also get some infolabels from the selected listitem and do stuff afterwards.
In your case you grab the title and stuff and launch the subtitles dialog. But again, I 'm not so sure you can launch that standalone so you'll endup writing your own subtitle scraper.
Reply
#5
You can open the subtitle addon as standalone, what I did is that I just added a condition inside that checks if "xbmc.Player().isPlaying():"
If true, it remain the same and took the title (xbmc.getInfoLabel("VideoPlayer.OriginalTitle")
If not, I put there a "fake" title just for getting "No subtitles found" message, and then if the action is "Manual search" I'm using the string which parsed from from the sys.argv[2] .

I will take a look in one of the context menu addons, and try to figure out what can I do.

The problem as I said is that the window which hold the item opens the subtitle dialog, and this dialog run the subtitle addon and pass it the arguments.
So my question is how can I control the subtitle dialog itself and take there the title using the getInfoLabel and send it as argument to the subtitle addon.

* Thanks for your help.
Reply
#6
I succeeded to get these info when I'm inside the subtitle addon:
22:16:38 T:9184 NOTICE: did: 10153
22:16:38 T:9184 NOTICE: Wid: 10025
22:16:38 T:9184 NOTICE: WinFocusID: 59
22:16:38 T:9184 NOTICE: WinFocus: <xbmcgui.ControlList object at 0x2389D578>
22:16:38 T:9184 NOTICE: control list size: 0

did = The active dialog id => subtitlesearch
wid = The active window id (Behind the dialog) => videos
win.GetFocusID => WinFocusID = 59 => ControlList? Panel?
win.GetFocus => WinFocus: <xbmcgui.ControlList object at 0x2389D578>
win.GetFocus.size() => control list size: 0 ========> Why 0? Is it not suppose to be more than zero?

EDIT: Here someone explain why it's empty, but I don't know how to solve this.
http://forum.kodi.tv/showthread.php?tid=...#pid856786
Reply
#7
You should do as I said... create a contextmenu addon, grab the labels first and than do whatever action you want.
In anyway you can't access the listitem container filled by kodi in python.
Reply
#8
The only issue with contextmenu, that when I'm inside external video addon, the item won't be shown in the context menu.
only in the libraries in kodi.

But Ok, my next question is: After I get the title from the item. How do I send this argument to the subtitles search dialog from my addon?
And how the subtitles search dialog will pass it to the subtitle addon after that?

* Currently, the subtitles dialog only pass the action (search/manualsearch), languages, preferredlanguage, searchstring (If action=manualsearch)
* When the subtitles search dialog is open, the default action which pass to the subtitle addon is "search" (Not manualsearch)
So I also need to know how can I change the action to "manualsearch" without use the Manual Search button.

When there is media which played, these are the args that the subtitle addon get from the subtitles dialog:
sys.argv[0]: plugin://service.subtitles.subscenter/
sys.argv[1]: 88
sys.argv[2]: ?action=search&languages=Hebrew&preferredlanguage=Hebrew
(And the search string comes from the video player inside the subtitle addon and not from the subtitles dialog)

And these on manual search action:
sys.argv[0]: plugin://service.subtitles.subscenter/
sys.argv[1]: 79
sys.argv[2]: ?action=manualsearch&languages=Hebrew&preferredlanguage=Hebrew&searchstring=TED
Reply
#9
By the way, I'm trying to open DialogSubtitles.xml like this:

PHP Code:
subsDialog xbmcgui.WindowXMLDialog("DialogSubtitles.xml","")
subsDialog.doModal() 

But I'm getting empty dialog like this:
Image

Instead of this:
Image
Reply
#10
Is someone can help me or give me any information about my last 2 posts?

Thanks.
Reply
#11
moving this the python dev...


as for your list post, that is expected behaviour.
you're opening a script window and load an xml file template.
next, it's up to your addon to fill the lists with content.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#12
Thanks.

Actually I want to open it exactly how Kodi opens it as usually and fill it with all the Subtitles addons.
How is it done by kodi? How can I implement this in my addon?

And the second question that I asked is how can I also transfer args to this dialog?
(Like kodi does when kodi is playing as I wrote in the example above)
Reply
#13
well there's no python method to open dialogsubtitles, so your addon can't do it 'like kodi does'.

you would have to code all of the needed functionality in your addon.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#14
As far as I know, currently you cannot launch a subtitle addon externally outside Kodi player.
Indeed, previously subtitle addons were full-featured scripts with their own GUI and all. So you could launch them outside Kodi player. But this was several years ago.

Now subtitle addons are a very special kind of plugins. They are very similar to, for example, video plugins, but they are run in a special environment: they are invoked by Kodi with a pre-difined paramstirng and they must return a ListItem object with pre-defined set of properties via xbmcplugin.addDirectoryItem() call.

PS. As ronie said, this basically means that you need to include subtitle downloading functionality in your addon.
Reply
#15
Regarding opening the subtitle dialog outside kodi player, I already done it.
* For opening the subtitles search dialog I'm defined it in the Keymap.
* For using the subtitle addon outside the kodi player, I just added a condition when Kodi is playaing or not, so when it's not, it's letting me use the Manual Search.
I don't use it for download subtitles (Though I do can download them), just for checking the result list from a specific subtitle addon to get an indication if subtitles are existed or see the release versions etc.
As I said, this is already done and it's working.

My next target is that instead of typying manually the string in the Manual Search, to take the title and pass it to the subtitle dialog.
So I started to create an external addon for this.
Currently, I have the title string. But the problem is as I mentioned -
1) Opening the subtittle search dialog with all the subtitle addons ("Like kodi does" Smile )
2) Sending the title string as an argument which pass it next to the specific subtitle addon (In the same pattern as I wrote previously)

So is it possible or there is no chance?
Is there other idea how to do that?

Thanks for your help
Reply

Logout Mark Read Team Forum Stats Members Help
Help: How to get Label/Title from an item & send to Subtitles dialog?0