Kodi Community Forum

Full Version: Play all video files from a nfs share
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a folder shared via nfs with a lots of animes that my daughter likes to watch. Usually I navigate to that folder and select to play the folder, then all the videos files in there are played fine.

Now I'm trying to create a script to automate this task, so I can put a link on the main screen of my skin so that my wife can eas[/code]ily play those videos for my daughter. The ideia of the script is to add all the videos to the playlist, shuffle it and start playing.

From some threads found here I have managed to do the following:

Code:
import os, xbmc

path="nfs://192.168.25.22/mnt/HDLivia/Series Kids/Galinha Pintadinha"

dirList=os.listdir(path)

videoList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
videoList.clear()

for fname in dirList:
    videoList.add(path + "/" + fname)

videoList.shuffle()
xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)")
xbmc.Player().play(videoList)


But it is not working. I got the following error (when calling os.listdir):

Code:
Error Contents: (2, 'No such file or directory', 'nfs://192.168.25.22/mnt/HDLivia/Series Kids/Galinha Pintadinha/

The nfs path is correct. Is it not working because nfs is not supported vy os.listdir? Or maybe because there are spaces on the pathname?

Anyone?

Thanks
Why not simply use a smart playlist?
(2015-03-19, 02:31)nickr Wrote: [ -> ]Why not simply use a smart playlist?

Couldn't get it to work with smart playlist because the video files I want to play are not in any video library.
Well theres your error then!
I don't think not wanting to use a video library in some cases is an error. In this nfs share there is thousands of video files that does not exist on any scrapper available so I can't automatically add them to the video library.

Please, anyone else could give me some help with this python script?

Thanks
Combine your solution and nickr's post.

So play the folder, go to now playing list and shuffle/save playlist.
Then add the playlist to the menu
(2015-03-26, 08:00)k4sh1n Wrote: [ -> ]Combine your solution and nickr's post.

So play the folder, go to now playing list and shuffle/save playlist.
Then add the playlist to the menu

Tried that and almost work except for one problem: Every time it plays the playlist on the same order. Already tried calling a suffle() command but it didn't work, because when you play a m3u playlist, kodi doesn't add the contents of the m3u file on the kodi's playlist. It adds just the current video, when it ends then it adds the next one.

So I guess I will have to use python to shuffle the m3u file before playing it, right?
Would it be easier to bind to keymap.xml
Link: http://kodi.wiki/view/List_of_built-in_functions

Look @ PlayerControl(command)

Allows control of music and videos. The command may be one of Play, Stop, Forward, Rewind, Next, Previous, BigSkipForward, BigSkipBackward, SmallSkipForward, SmallSkipBackward, Random, RandomOn, RandomOff, Repeat, RepeatOne, RepeatAll, RepeatOff, Partymode(music) or Partymode(video) or Partymode(path to .xsp file), and Record. Play will either pause, resume, or stop ffwding or rewinding. Random toggles random playback and Repeat cycles through the repeat modes (these both take an optional second parameter, Notify, that notifies the user of the new state). Partymode(music/video) toggles the appropriate partymode, defaults to music if no parameter is given, besides the default music or video partymode you can also pass a path to a custom smartplaylist (.xsp) as parameter.
It didn't worked because when you play a m3u playlist, kodi doesn't trow all the videos to its playlist, instead it plays one at once. When the current one finishes, it plays the next one from the m3u file.

I tried to create a python script that reads the m3u file and add all the videos on the kodi's playlist, shuffle it and then plays. This is the script:

Code:
import os, xbmc

videoList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
videoList.clear()

f = open('/storage/.kodi/userdata/playlists/video/Galinha Pintadinha.m3u')
line = f.readline()
while line:
    li=line.strip()
    if not li.startswith("#"):
        videoList.add(line)
    line = f.readline()
f.close()

videoList.shuffle()
xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)")

xbmc.Player().play(videoList)

But it didn't worked. Here is some of the output of the kodi's log:

Code:
20:47:23 T:1968582656  NOTICE: DVDPlayer: Opening: nfs://192.168.25.22/mnt/HDLivia/Series Kids/Galinha Pintadinha/2.12 - Pombinha Branca (720p).mp4
20:47:23 T:1158673472  NOTICE: Thread DVDPlayer start, auto delete: false
20:47:23 T:1158673472  NOTICE: Creating InputStream
20:47:23 T:1158673472   ERROR: CDVDPlayer::OpenInputStream - error opening [nfs://192.168.25.22/mnt/HDLivia/Series Kids/Galinha Pintadinha/2.12 - Pombinha Branca (720p).mp4
                                            ]
20:47:23 T:1158673472  NOTICE: CDVDPlayer::OnExit()
20:47:23 T:1968582656   ERROR: Playlist Player: skipping unplayable item: 2, path [nfs://192.168.25.22/mnt/HDLivia/Series Kids/Galinha Pintadinha/2.12 - Pombinha Branca (720p).mp4
                                            ]
20:47:23 T:1968582656  NOTICE: CDVDPlayer::CloseFile()
20:47:23 T:1968582656  NOTICE: DVDPlayer: waiting for threads to exit
20:47:23 T:1968582656  NOTICE: DVDPlayer: finished waiting

Note that the path "nfs://192.168.25.22/mnt/HDLivia/Series Kids/Galinha Pintadinha/2.12 - Pombinha Branca (720p).mp4" is correct, but I'm wondering why there is some spaces after it.

Thanks
I found that if you leave shuffle left on when playing the list from inside KODI playlist will play @ random. Turned on from now playing list.
Should only effect if music is in a queue.

If you play movies/TV shows you would watch individually, shuffle doesn't matter as there is no queue items to shuffle.

If you don't use a playlist for anything else other than folder played above I'd see it as probably an easier workaround.