How to get a link to play
#1
Brick 
Hi community,
So far i have this...
https://www.dropbox.com/s/mhlrciguow0wd8...1.jpg?dl=0

I have this playlist from youtube that

Code:
plugin.video.youtube/channel/UCzoE2GeGTIcSiBmLoOLYsWQ/playlist/PL7-PRrKey3Ht_b5QcxIdHz2ivScTBCyEV/

I want to link to this script
Code:
url = build_url({'mode': 'folder', 'foldername': 'Fort Apache'})
    li = xbmcgui.ListItem('Fort Apache', iconImage='##I have the url is long so I didnt put it in here##')
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
                                listitem=li, isFolder=True)

So basically I want to call the youtube addon to play this link until I learn how to add the playlist with my own code.

Can someone guide as to how to do this please, thanks a million
Reply
#2
Assuming that the youtube plugin url is correct and addon_handle is correct, I see 3 things you need to do:

1) add the prefix "plugin://" to the playable url, "plugin://plugin.video.youtube/channel/UCzoE2GeGTIcSiBmLoOLYsWQ/playlist/PL7-PRrKey3Ht_b5QcxIdHz2ivScTBCyEV/"

2) set the listitem property for playable after creation : li.setProperty('IsPlayable', 'true')

3) in xbmcplugin.addDirectoryItem call isFolder should be False: isFolder=False
Reply
#3
Hi learningit,

so far the code looks like this.
Code:
import sys
import urllib
import urlparse
import xbmcgui
import xbmcplugin

base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
args = urlparse.parse_qs(sys.argv[2][1:])
#Ive put this in, incase I need it later on.
#USER_AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
#url = "plugin://plugin.video.youtube/channel/UCzoE2GeGTIcSiBmLoOLYsWQ/playlist/PL7-PRrKey3Ht_b5QcxIdHz2ivScTBCyEV/"

xbmcplugin.setContent(addon_handle, 'movies')

def build_url(query):
    return base_url + '?' + urllib.urlencode(query)

mode = args.get('mode', None)

if mode is None:
    url = build_url({'mode': 'folder', 'foldername': 'La Tuerka'})
    li = xbmcgui.ListItem('La Tuerka', iconImage='https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/c1.12.198.198/p200x200/1391926_802431306482807_5209982344157037874_n.jpg?oh=87a2404278fea32a26a250a4523dc57f&oe=5630C349&__gda__=1442366553_a9adafb684266a60b2bc7167302dad27')
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
                                listitem=li, isFolder=False)

    url = build_url({'mode': 'folder', 'foldername': 'Fort Apache'})
    li = xbmcgui.ListItem('Fort Apache', iconImage='https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfa1/v/t1.0-1/c141.48.605.605/s200x200/317957_486451204732027_1397383078_n.jpg?oh=89208695f407d81dac7537ebdd4f6d6e&oe=55EFA3E5&__gda__=1442217467_4aea5311933870aca3ba4b5a1d0ac9dd')
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
                                listitem=li, isFolder=False)
                                
    url = build_url({'mode': 'folder', 'foldername': 'Podemos'})
    li = xbmcgui.ListItem('Podemos', iconImage='https://yt3.ggpht.com/-XnEVMjAnm84/AAAAAAAAAAI/AAAAAAAAAAA/oa-nlCnsrpY/s176-c-k-no/photo.jpg')
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
                                listitem=li, isFolder=False)                                


    xbmcplugin.endOfDirectory(addon_handle)

elif mode[0] == 'folder':
    foldername = args['foldername'][0]
    url = 'http://localhost/some_video.mkv'
    li = xbmcgui.ListItem(foldername + ' Videos', iconImage='icon.png')
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
    xbmcplugin.endOfDirectory(addon_handle)

can you please explain where I'm going wrong.
I cant see where id put
Code:
li.setProperty('IsPlayable', 'true')
or where Id put the youtube link
Code:
"plugin://plugin.video.youtube/channel/UCzoE2GeGTIcSiBmLoOLYsWQ/playlist/PL7-PRrKey3Ht_b5QcxIdHz2ivScTBCyEV/"

Thanks a million. I really want to get the hang of this, as I have some great ideas that I want to put into practise for the community.
Reply
#4
I'm not really sure I understand what you're trying to do in the above. I thought you wanted to play a url via the youtube addon, in which case you need to modify the url as I described earlier. The code you have above looks like you're trying build folders and then add a play url for a local .mkv file which is an entirely different deal than you described earlier.

For playable listitems (not folders):
li.setProperty('IsPlayable', 'true')
goes before
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

The isFolder=False should only be used on listitems with playable urls, not the folders(actually the default is isFolder=False (I think?)). Folders should be isFolder=True.

The best way to understand this is to look at a working addon to see how the playable urls are set up.

EDIT: I think you are copying the addon from Audio-video_add-on_tutorial (wiki) which isn't complete. It leaves out the li.setProperty('IsPlayable', 'true') for the playable url because a local file is being played. To play a plugin url you need to set it (hopefully I'm not full of crap on this, I know it's needed when using xbmcplugin.setResolvedUrl, not so sure if using xbmc.player().play). You can read the discussion here between 2 programmers much better than I am: 1568308 (post) about some issues when using this with a playlist.

so the code would look like this if you want to play a youtube url (assuming the one you have is correct) instead of a local .mkv:

Code:
elif mode[0] == 'folder':
    foldername = args['foldername'][0]
    url = "plugin://plugin.video.youtube/channel/UCzoE2GeGTIcSiBmLoOLYsWQ/playlist/PL7-PRrKey3Ht_b5QcxIdHz2ivScTBCyEV/"
    li = xbmcgui.ListItem(foldername + ' Videos', iconImage='icon.png')
    li.setProperty('IsPlayable', 'true')
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
    xbmcplugin.endOfDirectory(addon_handle)

and you need to go back and change the 3 occurrences of isFolder=False to isFolder=True in the code before the above
Reply
#5
(2015-06-19, 04:15)learningit Wrote: I'm not really sure I understand what you're trying to do in the above. I thought you wanted to play a url via the youtube addon, in which case you need to modify the url as I described earlier. The code you have above looks like you're trying build folders and then add a play url for a local .mkv file which is an entirely different deal than you described earlier.

For playable listitems (not folders):
li.setProperty('IsPlayable', 'true')
goes before
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

The isFolder=False should only be used on listitems with playable urls, not the folders(actually the default is isFolder=False (I think?)). Folders should be isFolder=True.

The best way to understand this is to look at a working addon to see how the playable urls are set up.

EDIT: I think you are copying the addon from Audio-video_add-on_tutorial (wiki) which isn't complete. It leaves out the li.setProperty('IsPlayable', 'true') for the playable url because a local file is being played. To play a plugin url you need to set it (hopefully I'm not full of crap on this, I know it's needed when using xbmcplugin.setResolvedUrl, not so sure if using xbmc.player().play). You can read the discussion here between 2 programmers much better than I am: 1568308 (post) about some issues when using this with a playlist.

so the code would look like this if you want to play a youtube url (assuming the one you have is correct) instead of a local .mkv:

Code:
elif mode[0] == 'folder':
    foldername = args['foldername'][0]
    url = "plugin://plugin.video.youtube/channel/UCzoE2GeGTIcSiBmLoOLYsWQ/playlist/PL7-PRrKey3Ht_b5QcxIdHz2ivScTBCyEV/"
    li = xbmcgui.ListItem(foldername + ' Videos', iconImage='icon.png')
    li.setProperty('IsPlayable', 'true')
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
    xbmcplugin.endOfDirectory(addon_handle)

and you need to go back and change the 3 occurrences of isFolder=False to isFolder=True in the code before the above

Hi learningit,

Yep, I was taking the basic code from audio-video addon tutorial.
Its a shame it not complete as I'm sure it would encourage a lot more people to try building addons for kodi, Im pretty close to giving up myself, although a voice in the back of my head says don't quit.
So progress is as follows.

Using your advice I can now get a YT url to play. Albeit with the incorrect title. That's fine for now. This is not an issue yet.

I've saved the playlist into kodi favourites and this is what I get.

Code:
ActivateWindow(10025,"plugin://plugin.video.youtube/channel/UCzoE2GeGTIcSiBmLoOLYsWQ/playlist/PL7-PRrKey3Ht_b5QcxIdHz2ivScTBCyEV/",return)

So I guess the next question is how do we call this in the code. I have tried
Code:
url  = "plugin://plugin.video.youtube/channel/UCzoE2GeGTIcSiBmLoOLYsWQ/playlist/PL7-PRrKey3Ht_b5QcxIdHz2ivScTBCyEV/"

The Youtube opening stream dialog appears along with the One or more items Failed to Play, Here is the Log File. Going through the kodi.log it does appear to get the playlist links
Reply
#6
Just to clear up one point, the tutorial is complete and correct for playing a local file, best as I can see. You're trying to play a plugin url, which is slightly different.

I can't play the YT url that you give on my test setup, so I'm not sure if it's valid or the format is valid. I would think that if it works as a favourite it would work as a plugin call as well. Possibly the addon is expecting the url encoded with urllib.quoteplus or you need to be logged in? If it works for you as a favourite, you need to ask about that in the YT thread. Your log is difficult to follow because you have a whole bunch of banned repos/addons messing around doing things at the same time.
Reply
#7
(2015-06-19, 13:22)learningit Wrote: Just to clear up one point, the tutorial is complete and correct for playing a local file, best as I can see. You're trying to play a plugin url, which is slightly different.

I can't play the YT url that you give on my test setup, so I'm not sure if it's valid or the format is valid. I would think that if it works as a favourite it would work as a plugin call as well. Possibly the addon is expecting the url encoded with urllib.quoteplus or you need to be logged in? If it works for you as a favourite, you need to ask about that in the YT thread. Your log is difficult to follow because you have a whole bunch of banned repos/addons messing around doing things at the same time.

Thanks for the help learnigit, im gonna go ahead and move onto YT thred, see how it goes, thanks for your dedication.
Reply

Logout Mark Read Team Forum Stats Members Help
How to get a link to play0