Kodi Community Forum

Full Version: [WIP] Loose Files, identify non-library files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This is a script I threw together for a friend of mine who suffered a catastrophic hardware failure and lost his media. While he had a 'backup', it was an old backup and so he lost all his carefully ascribed naming and folder structure. Some of his files will be picked up by XBMC, but too many wont be, and he needs a way to identify the files that havent been added to the library.

Loose Files scans your source folders and compares those files to the ones in your library, with the aim of identifying the files not picked up by XBMC. It provides you a list of those files on-screen. It can also save the list to disk or send it to you via email. The on-screen list gives you the option to play the file (to see what it is) or rename it. If you rename it the options change to allow you to rename it again, or move it to a new folder.

The script looks for 7 specific file types (avi, mkv, mpg, mpeg, mp4, wmv, mov), and you can either switch these file types off or add your own in the Settings. You can also set the script to ignore files below certain sizes.

Source: https://github.com/KODeKarnage/script.loosefiles
Download: https://github.com/KODeKarnage/script.lo...master.zip
Looks like python doesnt walk along SMB paths, so the script wont currently work with SMB shares.

I will look into a workaround for that. Happy to hear suggestions though.

I am going to start by looking at smbclient.py, which may work even if it means I have to do my own 'walking'. https://bitbucket.org/nosklo/pysmbclient/wiki/Home
You can walk the directories (smb, nfs, whatever) using JSON "Files.GetDirectory", have a look at the"missing" option of the script in my sig which does this.
Thanks!

I did try using that method, but my query always failed to parse. I suspect a Windows backslash issue.
Now here's a thought. Why dont I just use your script to identify the files? Smile
Mines a pure script, that runs entirely outside of XBMC (which has some advantages/disadvantages)... isn't yours an addon of some sort that runs within XBMC? Some people prefer that.
Yep, I was thinking about calling your script twice with two arguments "missing movies" and "missing tvshows". But keeping the front-end element in the Addon.

I only want the "missing" part of the script, and could just excise the code I need, I suppose. We'll just see how that goes.

Someone has pointed out the Missing Movie Scanner addon/plugin, which I didn't know about! Looks like a fertile field of development Smile
Fixed the SMB walking problem so it works with shares. Using the json-rpc, and its so much faster too.

Next I am going to look at accommodating RAR and ZIP files and maybe throwing in a context menu for the actions.
May also look to generate a list of duplicates, or identify which non-library files have duplicates in the library.
I have added in the ability to search specific terms when looking for loose files, but also across all files if you like.

The file scan is cached so you can switch that off to save a little time.
Moved the Rename and file move functions to a context menu, so main click now plays the item.

Also fixed the search to work a bit faster.
Replying so as to subscribe, will post error messages later when on proper computer.
Thanks nickr, testers always welcome!
(2014-04-20, 04:51)Karnagious Wrote: [ -> ]Thanks nickr, testers always welcome!
Sorry its not a debug log, nor a full log, if you need those for this particular problem I'll gladly do one.

The addon does through the directories (you can see filenames flash past) and then an error message pops up. This is the log:

Quote:13:18:04 T:139934706943744 NOTICE: Thread LanguageInvoker start, auto delete: false
13:18:04 T:139934706943744 NOTICE: -->Python Interpreter Initialized<--
13:18:25 T:139933884851968 NOTICE: Thread RarFileExtract start, auto delete: false
13:18:52 T:139934706943744 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-
-
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.UnicodeEncodeError'>
Error Contents: 'ascii' codec can't encode character u'\xbd' in position 34: ordinal not i
n range(128)
Traceback (most recent call last):
File "/storage/.xbmc/addons/script.loosefiles-master/default.py", line 642, in <module>
f = scan_files(lp, extensions)
File "/storage/.xbmc/addons/script.loosefiles-master/default.py", line 237, in scan_file
s
f.write(a + '\n')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in position 34: ordinal n
ot in range(128)
-->End of Python script error report<--
Ah, one of those pesky unicode errors. I hate them.

I have added a "fix" to the search branch. Let me know how it goes. Thanks.
Pages: 1 2