• 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7
Your 2nd Add-On: Online Videos!
#61
To be able to select view modes for your media listing you need to set media type of your media items: https://github.com/romanvm/plugin.video....in.py#L119

Also, switching view modes (although it is strongly discouraged) needs to be done after endOfDirectory call.
Reply
#62
python:
xbmcplugin.setContent(_handle, 'videos')
Yes!
that was the line i missed, with this (but without
python:
xbmc.executebuiltin('Container.SetViewMode(57)')
) the sideblade menu unlocked

I've misunderstood this function, i was believing that was only for the page which should display the final videos, and i was displaying just picture of the show (a folder in my mind) which when you click on it open another folder (season)

Thank a lot for your help! Smile
Reply
#63
Hello, 
Thanks to this tutorial I made an addon of online videos with subtitles.
Unfortunately when I tried to play the videos with a remote : the subtitles disappear.
I just add those two lines inside the main.py file :
python:
subtitles = domain+video['sub']+'.srt'
list_item.setSubtitles([subtitles])
It's working with the usual playing mode, maybe I should add more things to recognize the subtitles by the remote too.
Thanks for your help
Reply
#64
Is there a way to create video "SubCategories"
The structure of the original add-on is

1) 'Animals'
-> 'Crab'
-> 'Alligator'
-> 'Turtle'

2) 'Cars'
-> 'Postal Truck'
-> 'Traffic'
-> 'Traffic Arrows'

etc.

I'm looking for something like this:
1) 'Animals'
-> 1A) 'Wild Animals'
---> 'Lion'
---> 'Tiger'
---> 'Zebra'

-> 1B) 'Domestic Animals'
---> 'Chicken'
---> 'Cat'
---> 'Dog'

-> 1C) 'Sea Animals'
---> 'Dolphin'
---> 'Goldfish'
---> 'Tuna'

Is possible to create something like this, modifying the main code?
Please advice. Thank you.
Reply
#65
@fsatark
Yes, you can have nested "virtual folders" as well to whatever depth you want. They are defined as the top-level "virtual folder" ListItems.
Reply
#66
@Roman_V_M

Thank you for your answer. Unfortunately I'm not educated enough to decode your answer and create the solution I need by my self.
I also search around for a while but I can't find an example to analyze and follow.
Is it possible to provide code as example?
Thanks in advance
Reply
#67
Hello, can you help me with this question? I think I probably made it in the wrong place because it's about this addon, here is the question: 342055 (thread)

Basically what I'm wondering is if it's possible for this addon to run the code that scrapes the source code of a website only when the video item is clicked? I just don't want to scrape the website 2 or 3 times everytime I want to click the item, and it even does the scraping if I don't really have the intention of clicking the link that uses this function.

Sorry if this is some python issue more than an addon issue, I'm having trouble understanding the way an addon runs, do the variables get reset every time an user clicks a folder or item?
Reply
#68
Hello,

Thank you for this video example addon.

I learned a a lot from it.

I have 1 question:

When i start a video i have no focus on de video screen and cannot exit the screen direct with my keyboard.

I have to left-click my mouse on the screen and after that i can exit the video with escape.

How is it possible in the addon to set focus on de video screen so you can exit it direct with esc on the keyboard without a mouse click?
Reply
#69
@n.kooij  Plugins do not have programmatic control over Kodi UI events. But it is not clear what you are trying to do and what you mean by "exit". By default Esc key switches to Kodi UI and a video continues to play in the background. You can switch between Kodi UI and a fullscreen video with Tab. And you can stop playback with X. Those are with the default keyboard layout.
Reply
#70
Hello,

attn: Roman_V_M

I found your tutorial very informative and useful. In tutorial you refer that data can be obtained by other means and I want go this route. But so far my attempt are not successful.

I want to read a file from local storage space and tried following code

```Python
import json
import codecs
fname = 'c:/temp/iptv/video_data.json'

with open(fname, encoding='utf-8') as f:
      data = f.read()
      VIDEO = json.loads(data)
```

The code produces an error in log file that open does not have encoding

I've attempted following approach

```Python
import json
import codecs
fname = 'c:/temp/iptv/video_data.json'

with open(fname, 'rb') as f:
      bytes = f.read()
      data = bytes.decode('utf-8')
      VIDEOS = json.loads(data)
```

The code produces an error 'ascii' codec can't encode characters in position 1-4: ordinal not in range(128)'.

I've looked for information about how I can read utf-8 encoded JSON file in KODI without success so far.

I see that KODI has python27.dll library and my guess it that first error is related to older version of python in some way.

Second code snippet works fine with python 3.8.2 outside of Kodi and I am confused with the error and at loss what causes it.

Ideally I would like to retrieve some data from DataBase through php,python,ruby code on webserver (and I can do it at this moment) form a JSON string which will be served by webserver to KODI plugin.video.example to process further.

Following code in which I attempted to capture utf-8 encode JSON file also produces an error

```Python
url = 'http://iptv.some_server.com/series.json'

html = client.request(url)
VIDEO = html.content
xbmc.log(VIDEO[0:10], xbmc.LOGNOTICE)
```

A ticket was created on Stackoverflow in hope to obtain required information to described issue.

Your guidance will be greatly appreciated, I do not mind to read some documentation related to this subject as at this moment I have very limited understanding about Kodi's internals of API.

Thank you in advance for your effort and time
Reply
#71
@Polar Bear Currently Kodi uses Python 2.7.  Moving to Python 3 is planned in the next version.
Reply
#72
(2020-05-10, 08:04)Roman_V_M Wrote: @Polar Bear Currently Kodi uses Python 2.7.  Moving to Python 3 is planned in the next version.
Roman,

can you demonstrate how to load data from webserver into VIDEO variable?

Your help greatly appreciated.
Reply
#73
(2020-05-11, 04:11)Polar Bear Wrote:
(2020-05-10, 08:04)Roman_V_M Wrote: @Polar Bear Currently Kodi uses Python 2.7.  Moving to Python 3 is planned in the next version.
Roman,

can you demonstrate how to load data from webserver into VIDEO variable?

Your help greatly appreciated. 

I don't see the point.  There are plenty of web servers with different data formats. And Python in Kodi is no different than regular Python. As for interacting with web servers in general, Python Requests library documentation is a good starting point.
Reply
#74
(2020-05-11, 21:18)Roman_V_M Wrote: I don't see the point.  There are plenty of web servers with different data formats. And Python in Kodi is no different than regular Python. As for interacting with web servers in general, Python Requests library documentation is a good starting point. 

Well,

above in the thread I provided a sample of the code -- it works outside of the Kodi, but in plugin.video.example it produces an error which is obscure and I could not decipher what caused it.

You can try it yourself and see produced error -- the code uses Requests library which you referred to. It was a reason why I asked you for assistance or give a sample of retrieving data from web server into VIDEO variable.

The file which I retrieve has same format you use for VIDEO variable in the plugin.

Outside Kodi the file retrieved successfully and loaded into dictionary successfully, data are accessible --  but it does not work in Kodi plugin.
Reply
#75
Horray,

finally figured out what was wrong - it works now!

html = requests.get(url)
VIDEOS = json.loads(html.content)

NOTE:
To be able load utf8 JSON file from a web server it requires to install 'script.modules.requests-2.22.zip' from zip file.

Then  add into 'addon.xml' file '<import addon="script.module.requests" version="2.22.0"/>'

<requires>
  ......
  <import addon="script.module.requests" version="2.22.0"/>
</requires>

At this stage KODI will complain about utf8 values in the hash. Values will require encoding which can be achieved as following

import json
import requests

url = 'http://iptv.server.com/series.json'

VIDEOS = {}
html = requests.get(url)
DATA = json.loads(html.content)

for v in DATA.keys():
    s = v.encode('utf-8')
    #xbmc.log(s, xbmc.LOGNOTICE)
    VIDEOS[s] = []
    for v in DATA[v]:
        name = v['name'].encode('utf-8')
        genre = v['genre'].encode('utf-8')
        #xbmc.log(name, xbmc.LOGNOTICE)
        #xbmc.log(genre, xbmc.LOGNOTICE)
        e = { "name": name, "thumb": v["thumb"], "video": v["video"], "genre": genre }
        VIDEOS[s].append(e)

Provided in hope that somebody will find it useful.
Reply
  • 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7

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