XBMC Community Forum
Playlistwalker (a playlist generator script) - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Python Add-on Development (/forumdisplay.php?fid=26)
+--- Thread: Playlistwalker (a playlist generator script) (/showthread.php?tid=10040)

Pages: 1 2


- thor918 - 2005-02-16 23:30

it walks trough folders on harddrive or a network share,
while it walks it generates a 'playlistwalker.m3u' file in each folder.
the playlist that is generated can consist of 'mp3','avi','jpg' or whatever.

hope this script will get more comments than my first script.

http://home.no.net/thor918/xbmc/playlistwalker.zip


- pike - 2005-02-17 00:37

nothing i need but new scripts are always appreciated.

sounds more like it "crawls" than "walks" :saint:


- thor918 - 2005-02-17 21:58

@pike
your right, it looks like a crawler Wink
the name is picked because of the phyton command for going trough folders and files  = os.walk
very logic  Tongue


-------------------------------------------------------
@all
to use the script you will have to copy lib files and extract them to the phyton lib directory on xbmc.
then extract the playlistwalker.py to scripts directory on xbmx.
after this you will have to add walk commands at the bottom of the playlistwalker.py script.

the command looks like this
if you want to crawl the harddrive of the xbox :
walkthehd('e:\\music\\test',['mp3','avi','jpg','mpg','mov'])

if you want to crawl a network share:
walkthesmb('share\\folder\\','computername', '10.0.0.6' , 'username' ,'password',['mp3','avi','jpg','mpg','mov'])

and remember to enable write premissions on the share.

you look at the share crawl command and say, is it really nesseasary to have both computername and ipadress.
then i say yes!
Tongue (the sharelib requier both values.don't ask me why)


- deemeph - 2005-02-18 00:53

great script i have been looking for something like this. thanks!


- thor918 - 2005-02-22 02:54

i'm glad at least one found it usefull Wink


- deemeph - 2005-02-28 00:42

okay this is great, but i have 2 comments, one would it be possible to name the playlist the same as the folder? and also i have a folder.jpg in each of my music folders (and some video but i use this script for music only) and i get the folder.jpg in each playlist not a big deal but if you could put something in to ignore these, also <filename>.tbn

other then that this is perfect, did about 500 music album folders in 2mins with no problems.

thanks again!


- thor918 - 2005-02-28 03:24

hi again.
name the playlist the same as the folder. yes

> ignore these, also <filename>.tbn
but it sholdn't add tbn files unless it is specified
walkthehd('e:\\music\\test',['mp3','avi','jpg','mpg','mov'])
(will add files with mp3,avi,jpg,mpg,mov but nothing else.)

i will checkit out. be right back


- thor918 - 2005-02-28 06:36

i added a new version now:
http://home.no.net/thor918/xbmc/playlistwalker2.zip

* discard folder.jpg
* added foldername in progressdialog
* added a variable to choose from [foldername].m3u or playlistwalker.m3u
 (if we are walking in the root the playlist will be playlistwalker.m3u always)


- EvilGoodGuy - 2005-03-04 03:13

first off great script. but i was wondering if you would help me with a few slight modifications. i'm not to good with advanced python so i can't do it myself.

1.) i would like to save the playlists named as the folder they were originated in in the designated playlist area so that a randomplaylist chooser can pick them out easily. i just didn't know where exactly in the write command the destination folder was. Tongue

2.) i have all of my music in a f:/mp3/artist/album format. could you possibly alter your code for me so that it will walk into each artist folder forming only one playlist containing all albums? i tried doing this myself, but ran into problems where it would just be overwritting the previous foler's playlist instead of adding to it.

if you could do this that would be wonderful, if not then no problem at all. thanks for the script so far, and i hope you have time for this modification :bowdown:


- Tomkun - 2005-03-04 15:45

i can't get this to work with my smb shares... what could i be doing wrong? can someone give me an example of how to edit the script properly? perhaps i did it wrong...


- thor918 - 2005-03-04 16:12

if i logon ip 10.0.0.6(ip 10.0.0.6 has the computer name "thorsdata") by my windows pc:
i will see these folders
e
f
printers

so i want to playlist genereate f

this works for me :
walkthesmb('f\\','thorsdata', '10.0.0.6' , 'administrator' ,'password',['mp3','avi','jpg','mpg','mov'])



---------------------------------------------------------
the only down thing is that for a unknown reason the share lib by "michael teo " will only return (max 30 files and folders ) for each folder prossessed.


@evilgoodguy
i will see if i can add something for you.
be right back.


- Tomkun - 2005-03-04 16:52

thanks thor, it works a treat now. i was missing a colon after my user name. d'oh!


- thor918 - 2005-03-05 01:29

new version:
http://home.no.net/thor918/xbmc/playlistwalker3.zip

command looks like this now
cleanthehd(['e:\\music']) #removes all playlist it findes in it's path Wink

#          walkdirectory,storebigplaylistdirectory
walkthehd(['e:\\music','e:\\playlists'],['mp3','avi','jpg','mpg','mov'])
this coomand will crawl trough the walkdirectory, and add all to a big file.the playlist will be named after the walkdirectory folder.so there is a chance for overwriting, but this can be avoided by different startfolder(from walkdirectory) names.

(perhaps i will change the storebiglistdirectory to a path and filename. that way it will be easier to store lists without the chance for overwriting existing playlist in that folder.let me know what you think)

#                walkdirectory
#walkthehd(['e:\\music'],['mp3','avi','jpg','mpg','mov'])

#walkthesmb(['f\\musikk\\'],'computername', '10.0.0.6' , 'username ,'password',['mp3','avi','jpg','mpg','mov'])

@tomkun
good to hear that you got it working  Big Grin


- thor918 - 2005-03-05 19:41

if there is any other tips or addons
for what you would like to see in this script i will do my best to add it Wink

perhaps there will be a gui for it someday.


- thor918 - 2005-03-05 23:56

a small little test to show that the lib for smb will only return about 30 files and folders each time it is called.

#--------------------smbtest.py----------------------------
import os, sys, string, socket
import smb, nmb

netbios = nmb.netbios()
print 'connecting to share.............'

remote = smb.smb('computername' , '10.0.0.3' )
remote.login('administrator', 'password')

#list = remote.list_path('share','folder\\/*.*')
list = remote.list_path('c','musikk\\/*.*')
print "total files found " + str(len(list))
#----------------------------------------------------

this has the same result on query of a smb share running on a win2000,winxp.
i did the test from xbox and win2000. same results.

the folder musikk has 50 files, and the smblib will return a total of 32 files. perhaps somebody else can nag the author about it.