Kodi Community Forum

Full Version: TV Shows Scraping can't find anything
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
using xbmc 8.10
my tv shows folder looks like this:
C:\Users\me\Downloads\--== uTorrent Downloads ==--\
30.Rock.S03E08.HDTV.XviD-LOL.avi
30.Rock.S03E09.HDTV.XviD-LOL.avi
House.S05E07.HDTV.XviD-LOL.avi
House.S05E08.HDTV.XviD-LOL.avi
The.Sarah.Silverman.Program.S03E05.DSR.XviD-iHT
The.Sarah.Silverman.Program.S03E07.DSRip.XviD-aAF
...
.
.
when this folder as source and sets contents as TheTVDB.com it scans but doesnt find anything.
is the folder and names problematic?
debug log?
It's not what i understood from http://www.xbmc.org/wiki/?title=Set_Cont...o_Library)
maybe i need to read it again
tzvikaz: I had the same problem and I fix it by running this script every few hours...

Code:
import os
import sys
import re
import shutil
import xbmc

def _mkdir(newdir):
    """works the way a good mkdir should :)
        - already exists, silently complete
        - regular file in the way, raise an exception
        - parent directory(ies) does not exist, make them as well
    """
    if os.path.isdir(newdir):
        pass
    elif os.path.isfile(newdir):
        raise OSError("a file with the same name as the desired " \
                      "dir, '%s', already exists." % newdir)
    else:
        head, tail = os.path.split(newdir)
        if head and not os.path.isdir(head):
            _mkdir(head)
        #print "_mkdir %s" % repr(newdir)
        if tail:
            os.mkdir(newdir)

src_dir = 'e:\\tvshow dump'
new_dir = 'e:\\tv'

for root, dirs, files in os.walk(src_dir):
    for name in files:      
        print name
        p=re.compile('(.+?)\.S([0-9]+)E([0-9]+).+?\.avi')
        match=p.findall(name)
        for filename, season, episode in match:
            try:
                filename = filename.replace(".", " ")
                filename = filename.replace("_", " ")
                newdir = os.path.join(new_dir,filename)
                _mkdir(newdir)
                shutil.move(os.path.join(src_dir,name), os.path.join(newdir,name.replace("_", ".")))
                   except:
                       print "Error moving " + name
                       
        p=re.compile('(.+?)\.([0-9]+)x([0-9]+).+?\.avi')
        match=p.findall(name)
        for filename, season, episode in match:
            try:
                filename = filename.replace(".", " ")
                filename = filename.replace("_", " ")
                newdir = os.path.join(new_dir,filename)
                _mkdir(newdir)
                shutil.move(os.path.join(src_dir,name), os.path.join(newdir,name.replace("_", ".")))
                   except:
                       print "Error moving " + name
                       
        p=re.compile('(.+?)\.([0-9]+)\.([0-9]+)\.([0-9]+).+?\.avi')
        match=p.findall(name)
        for filename, year, month, day in match:
            try:
                filename = filename.replace(".", " ")
                filename = filename.replace("_", " ")
                newdir = os.path.join(new_dir,filename)
                _mkdir(newdir)
                shutil.move(os.path.join(src_dir,name), os.path.join(newdir,name.replace("_", ".")))
                   except:
                       print "Error moving " + name
                       
xbmc.executebuiltin('XBMC.updatelibrary(video)')
How do I run this script?
tzvikaz Wrote:It's not what i understood from http://www.xbmc.org/wiki/?title=Set_Cont...o_Library)
maybe i need to read it again
The silly tree was meant to represent different directories.
I have fixed it a bit.
tzvikaz Wrote:How do I run this script?

Create a new folder in your scripts directory, I named mine TVShowMover.

Copy and paste the code to a file called default.py in the directory you just created.

Change the src_dir & new_dir variables to suit your needs. (Make sure the new_dir is a valid video source)

In XBMC go to scripts and run TVShowMover
thanks!
unfortunately my files are all in a different pc.
can i change the script so it would work on a remote machine without mapping network drive?
cant you just run it on that 'different' pc ?
I dont want to install and run xbmc on that pc for the sole reason of running this script
sorry didn't realize it was a xbmc-python script.
tzvikaz Wrote:I dont want to install and run xbmc on that pc for the sole reason of running this script

Map a drive and run it. Install python and remove the xbmc references...
ill try that
thanks