• 1
  • 2
  • 3(current)
  • 4
  • 5
  • 7
Your 2nd Add-On: Online Videos!
#31
Hi, Im really new at this, and I would appreciate if anybody could help me a bit.... I imagine Im doing several horrible errors Sad

I tried editing the example plugin, because I wanted to achieve the following:

1) The plugin asks the user for 3 different variables, channel, date and show start time
2) Then, the plugin concatenates (joins) those variables with some other text to form an url
3) Finally, Kodi opens the resulting url.

This is the code I use, but KODI is unable to run the plugin.... any help? Thanks in advance!

import sys
import xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin

addon = xbmcaddon.Addon()
addonname = addon.getAddonInfo('name')

keyboard = xbmc.Keyboard("", "Type your channel: 01 for Channel1, 02 for Channel2, 03 for etc", False)
keyboard.doModal()
if keyboard.isConfirmed() and keyboard.getText() != "":
channel = "chanchan"&(keyboard.getText()
line1 = "You have selected channel %s" %(keyboard.getText())
xbmcgui.Dialog().ok(addonname, line1)

keyboard = xbmc.Keyboard("", "Type your show date using format yyyymmdd", False)
keyboard.doModal()
if keyboard.isConfirmed() and keyboard.getText() != "":
showdate = (keyboard.getText()
line2 = "You have input date %s" %(keyboard.getText())
xbmcgui.Dialog().ok(addonname, line2)

keyboard = xbmc.Keyboard("", "Type your show start time using format hhmm", False)
keyboard.doModal()
if keyboard.isConfirmed() and keyboard.getText() != "":
showtime = (keyboard.getText()
line3 = "You have input start time at %s" %(keyboard.getText())
xbmcgui.Dialog().ok(addonname, line3)

xbmc.executebuiltin("PlayMedia(http://201.42.15.192/ %(showdate) %(showtime) %(channel).mp4)")
Reply
#32
So I downloaded the ZIP file for this tutorial and noticed that it has two files in it that don't need to be there (.gitignore and readme.md). I removed .gitignore from the ZIP file and then try to install the add-on but Kodi then says "Failed to install Add-on from zip file". Alright, now I turn on debugging to see what I'll find in the logs and try again. Unfortunately, the logs don't tell me anything useful as to why the add-on failed loding:

Code:
18:20:50 T:3808   DEBUG: ------ Window Deinit (FileBrowser.xml) ------
18:20:50 T:3808   DEBUG: CAddonInstaller: installing from zip 'D:\Development\Kodi\plugin.video.example-master.zip'
18:20:50 T:3808   DEBUG: ------ Window Init (DialogKaiToast.xml) ------

Why would deleting that one file cause the add-on to fail loading? Should I found more information in the logs than that?

I'm using Kodi 16.0 on Windows.

Thanks!
Reply
#33
(2016-04-13, 02:23)DigitalLachance Wrote: So I downloaded the ZIP file for this tutorial and noticed that it has two files in it that don't need to be there (.gitignore and readme.md). I removed .gitignore from the ZIP file and then try to install the add-on but Kodi then says "Failed to install Add-on from zip file". Alright, now I turn on debugging to see what I'll find in the logs and try again. Unfortunately, the logs don't tell me anything useful as to why the add-on failed loding:

Code:
18:20:50 T:3808   DEBUG: ------ Window Deinit (FileBrowser.xml) ------
18:20:50 T:3808   DEBUG: CAddonInstaller: installing from zip 'D:\Development\Kodi\plugin.video.example-master.zip'
18:20:50 T:3808   DEBUG: ------ Window Init (DialogKaiToast.xml) ------

Why would deleting that one file cause the add-on to fail loading? Should I found more information in the logs than that?

I'm using Kodi 16.0 on Windows.

Thanks!

Did you just open the archive, remove the file, and then close the archive? This may have caused the zip file to get borked. I think the best practice is to extract the zip to a folder, remove the file, and then re-zip. I'm not a Windows user, so not sure which archive program is best for this, or if the built-in Windows archiving utility is sufficient.

Also, I don't recall having any issues installing from a zip that had extra files. Have you tried installing the zip as downloaded?
Kodi Nexus on Dell Optiplex 980 Lubuntu 20.04 | Kodi Nexus on HTPC Lubuntu 20.04 | My Add-ons | Legacy Repo | Matrix Repo
Reply
#34
Thank you for the quick reply!

Quote:Did you just open the archive, remove the file, and then close the archive?
Yes, that's what I did.
Quote:This may have caused the zip file to get borked. I think the best practice is to extract the zip to a folder, remove the file, and then re-zip. I'm not a Windows user, so not sure which archive program is best for this, or if the built-in Windows archiving utility is sufficient.
No, I know that the zip file is not messed up because I can open it again and extract it just fine. I use 7-Zip because the built-in windows archiving is very basic and sucks.

Quote:Also, I don't recall having any issues installing from a zip that had extra files. Have you tried installing the zip as downloaded?
There is no issue installing the zip as downloaded at all. But because I'm new at this, I just wanted to experiment with small changes, one at the time.

It would seem that if I exit from Kodi and re-start it, it will then install that zip file without any error. Kind of annoying if you need to test small updates to the zip file.

Should there be more information in the kodi.log file about the error?

Maybe I'm going about this the wrong way. If I want to test changes to my code, do I have to re-install the zip file with every update that I want to test?

Thank you for your help!
Reply
#35
(2016-04-13, 02:23)DigitalLachance Wrote: So I downloaded the ZIP file for this tutorial and noticed that it has two files in it that don't need to be there (.gitignore and readme.md).

Extra files do not matter. However, the zip on the repo main tab is automatically generated by GitHub and is not meant for installing in Kodi. Installable zips can be downloaded from "Releases" tab.

As for quick experiments, it's better to do them in place. When I want to quickly check/try something, I launch Kodi, switch to Total Commander with Alt+Tab and open addon files in SublimeText. You don't need to re-launch Kodi -- change your code, switch back to Kodi, try the code, change it again if necessary, and repeat until you are done.
Reply
#36
Hello,

Is it possible(how?) to show images for a video addon?

I've started my learning by modifying the Reddit plugin by J.Mikkonen and addonscriptorDE.
A lot of Reddit post come from Imgur. I got the videos(gifv) working but could not get the images to show.
It would be convenient for the user to be able to see an image post without exiting and calling the addon as a picture addon.
Reply
#37
You should start a new thread - this question is unrelated to this thread.
Reply
#38
A very simple question...
I am following wiki's video addon, it can be possible to run a script instead of playing a video changing "url" variable?

Code:
import sys
import xbmcgui
import xbmcplugin

addon_handle = int(sys.argv[1])

xbmcplugin.setContent(addon_handle, 'movies')

url = 'http://localhost/some_video.mkv'
li = xbmcgui.ListItem('My First Video!', iconImage='DefaultVideo.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

xbmcplugin.endOfDirectory(addon_handle)

I just want to make a simple list with 2 or 3 actions for running bash or python scripts and I wonder if I can use something like:

Code:
url='System.Exec(/storage/path_to_my_script.sh)'

I can not make it work... any help?

thanks!
Reply
#39
I saw this got removed from the wiki but its worth posting here as it has some good tips on writing a new add-on



It also has some good bits for Radio links such as the BBC
Reply
#40
PLease Help Me AS i am New to python,and working on my 2nd video Addon ,

And video links are on this site

http://ok.ru/videoembed/93942254125

and tihs link work only in browser but not in Vlc as a test



So:

How can i include this To My Addon
=============================
i found Answer But not sure how to include it in my Addon
Code:
import urllib, urllib2, urlparse, re, json

HEADERS = {
    'User-Agent':      'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36',
    'Accept':          'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Cache-Control': 'no-transform'
}

def http_req(url, getCookie=False, data=None, customHeader=None):
    if data: data = urllib.urlencode(data)
    req = urllib2.Request(url, data, HEADERS)
    if customHeader:
        req = urllib2.Request(url, data, customHeader)
    response = urllib2.urlopen(req)
    source = response.read()
    response.close()
    if getCookie:
        cookie = response.headers.get('Set-Cookie')
        return {'source': source, 'cookie': cookie}
    return source

sources = []

mirrorUrl = 'http://www.ok.ru/videoembed/36530555610'

try:
    id = re.search('\d+', mirrorUrl).group(0)
    u = urlparse.urlparse(mirrorUrl)
    hostUrl = '://'.join([u.scheme, u.netloc])
    jsonUrl = 'http://ok.ru/dk?cmd=videoPlayerMetadata&mid=' + id
    jsonSource = json.loads(http_req(jsonUrl))

    quality = {
        'mobile': '144p',
        'lowest':  '240p',
        'low':      '360p',
        'sd':       '480p',
        'hd':       '720p',
        'full':      '1080p'
    }
    
    for source in jsonSource['videos']:
        q = source['name'].strip()
        q = quality.get(q, None)
        if not q:
            continue
        name = '%s %s' % ('[ok.ru]', q)
            'User-Agent':   HEADERS['User-Agent'],
            'Referer':      mirrorUrl,
            'Origin':       hostUrl
        }
        params = '&'.join(['%s=%s' % (k, urllib.quote_plus(v)) for k, v in params.iteritems()])
        link = '%s|%s' % (source['url'], params)
        
        item = {'name': name, 'url': link}
        sources.append(item)
except:
    pass

print sources

or shoulg i make it as util.pay and how to import it to my default.py
Reply
#41
I like to do something similar but with magnet link torrent?
Reply
#42
Because it is my first post here on the forum , I would like to say hello to everyone.

Is someone can explain me why when I am changing a link from

'Cars': [{'name': 'Postal Truck',
'thumb': 'http://www.vidsplay.com/vids/us_postal.jpg',
'video': 'http://www.vidsplay.com/vids/us_postal.mp4',
'genre': 'Cars'},

to

to 'Cars': [{'name': 'Postal Truck',
'thumb': 'http://www.vidsplay.com/vids/us_postal.jpg',
'video': 'https://www.youtube.com/watch?v=Tstr7D0bXhQ',
'genre': 'Cars'},


I can not play a copied youtube link( or any other video link not just youtube) in kodi. When I copy a video link from any other place of script to the Postal Truck it works. Is this a problem that setResolvedUrl can not play a youtube video format? I am using original kodi video addon form this tutorial.

I am really green in coding so if you have any other good video addon tutorial I will really appreciate it
Reply
#43
A youtube link is not a video, its a webpage showing a video. Totally different thing!

Have a look at my youtube guide here for more info.

http://forum.kodi.tv/showthread.php?tid=254207
Reply
#44
Hello Everyone, this is my first post.
I really like what Roman has created and it has kept me busy for the last few days Wink
I do have one question and hope someone can explain to me how it's done, or want to help if possible. Any help is appreciated.

I have installed this plugin in my KODI and I was just wondering if it's possible to have the main.py file with the links located on my hosting account online, so I can update it constantly with new links, so when this addon starts, it will connect to that file and pull all the new information (links) from it.

Thanks.
Reply
#45
(2017-01-09, 04:36)JETZEE Wrote: Hello Everyone, this is my first post.
I really like what Roman has created and it has kept me busy for the last few days Wink
I do have one question and hope someone can explain to me how it's done, or want to help if possible. Any help is appreciated.

I have installed this plugin in my KODI and I was just wondering if it's possible to have the main.py file with the links located on my hosting account online, so I can update it constantly with new links, so when this addon starts, it will connect to that file and pull all the new information (links) from it.

Thanks.

The purpose of my example video addon is to demonstrate how to work with Kodi Python API to present lists of media content in Kodi. I used hardcoded video links to make the example plugin as generic as possible.

Unfortunately, there seems to be some common misconception among novice addon developers that Python in Kodi is completely different from Python programming language developed and promoted by Python Software Foundation. Well, it's not. So instead of asking "how to do something in Kodi" novice addon developers should ask "how to do something in Pyhon". And usually the answers for the latter question can easily be found in Google/Bing. Python is a popular programming language and there are a lot of info in the Internet on how achieve this or that task. Tasks like "how to make requests to a web-site", "how to scrap info from a web-page", "how to work with XYZ API", "how to login to a web-site problematically" and such are not Kodi-specific really. There are a lot of documentation, manuals, tutorials, StackOverflow answers for that matter that describe how to do various things in Python.

In your case, reading info from a text file is a bask task that should be covered in any descent Python book.
Reply
  • 1
  • 2
  • 3(current)
  • 4
  • 5
  • 7

Logout Mark Read Team Forum Stats Members Help
Your 2nd Add-On: Online Videos!2