ddurdle / Hive-for-KODI

An Hive (QVIVO) Video/Music add-on for Kodi / XBMC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integration with thetvdb

ddurdle opened this issue · comments

Mechanism to catalog media files against thetvdb.

commented

Hi ddurdle,

I would like to contribute on that subject. What I did so far is just add this to the hive.py buildSTRM function:

        if url != 0:
                    if not os.path.exists(path + item.file.title+'.strm'):
                        filename = xbmc.translatePath(os.path.join(path, item.file.title+'.strm'))
                        strmFile = open(filename, "w")

                        strmFile.write(url+'\n')
                        strmFile.close()
         # MY ADDITION:
                    pathLib = ''
                    regtv = re.compile('(.+?)'
                                       '[ .]S(\d\d?)E(\d\d?)'
                                       '.*?'
                                       '(?:[ .](\d{3}\d?p)|\Z)?')
                    regmovie = re.compile('(.*?[ .]\d{4})'
                                          '.*?'
                                          '(?:[ .](\d{3}\d?p)|\Z)?')
                    tv = regtv.match(item.file.title)
                    if tv:
                        show = tv.group(1).replace(".", " ")
                        season = tv.group(2)
                        pathLib = self.addon.getSetting('tvshows_path') + '/' + show
                        if not xbmcvfs.exists(xbmc.translatePath(pathLib)):
                            xbmcvfs.mkdir(xbmc.translatePath(pathLib))
                        pathLib = pathLib + '/Season ' + season
                        if not xbmcvfs.exists(xbmc.translatePath(pathLib)):
                            xbmcvfs.mkdir(xbmc.translatePath(pathLib))
                    else:
                        movie = regmovie.match(item.file.title)
                        if movie:
                            pathLib = self.addon.getSetting('movies_path')

                    if pathLib != '':
                        if not os.path.exists(pathLib + item.file.title+'.strm'):
                            filename = xbmc.translatePath(os.path.join(pathLib, item.file.title+'.strm'))
                            strmFile = open(filename, "w")
                            strmFile.write(url+'\n')
                            strmFile.close()

It just needs a path for movies and one for tv shows. This allows in most cases the creation of the correct folder structure so that the Kodi library scraper can do it's thing. If I just sync my video folder it is a quick way to build a library, with metadata, of my cloud content.

Hope this can help and I hope to be able to contribute in the future. I'll start working on a french locale :)

It's like you read my mind :) The other day I was playing around with TV content to see what the default TV scraper was looking for. Deemed that as long as the episodes can be grouped under a folder with the TV show name, they'll be picked up. So I was thinking, during the construction of the STRM files, just determine if the title has "season and episode" numbers in it, then group it into a directory reflective of the title of the show. From my scraping tests, I don't think it needs to be broken down further by season. Maybe you've seen otherwise. It couldn't hurt I guess.

I have literally thousands of episodes all ready to be imported into my XBMC from my google drive. The change you have suggested can be applied for both the Hive and Google Drive plugins :)

I'll push out your change with the subfolder fix.

commented

Cheers :) And yes I think they need to be broken down by season as well and it doesn't hurt :)

I am trying to look into Music playpack and sync with the Kodi library as well. Seems like the good option here would be to still use .strm along with .nfo with all the ID3 tags info.

Edit: maybe the season thing is from older versions of xbmc

I forgot about music files completely. Agreed, everything should be already there for generating the NFO files.

commented

I am very sorry I just spotted a mistake...

tv = regtv.match(item.file.title.upper())

We want to match the title in upper case for the regexp.

I'll add it to the next release.

commented

This has the side effect to create the tv show folders names in uppercase as well. I personally don't care but some users might. Could easily rework the uppercase string into a normal "Case" string.

Any opinion on SSxEE? I had a STRM file that got picked up by the TV scraper. I'm thinking about checking what the regex the TV scarper uses and reuse it.

For the uppercase issue, guess just make a copy of the variable that hasn't been modified to use for the directory naming,

commented

yep I have been looking at those docs as well. Problem with saving the initial var is that the regexp is also doing the string slice, so slices will be uppercase. It's solvable easily I'll look into it.

As for the SSxEE format it would need another regexp or maybe we could make an xbmc script module out of this: https://github.com/wackou/guessit

from guessit import guess_file_info
guess_file_info('Treme.1x03.Right.Place,.Wrong.Time.HDTV.XviD-NoTV.avi')

{u'mimetype': 'video/x-msvideo', u'episodeNumber': 3, u'videoCodec': u'XviD', u'container': u'avi', u'format':     u'HDTV', u'series': u'Treme', u'title': u'Right Place, Wrong Time', u'releaseGroup': u'NoTV', u'season': 1, u'type': u'episode'}

Could be useful for other addons as well.

It would also mean the user would have to have it installed

I've updated the plugin with a dirty trick to get it working.

I pushed the original contribution to gdrive plugin.

I ran it against the Google Drive. A very first good run. Some room for improvement.

Now I'm starting to think forcing everything to uppercase would be actually beneficial. It would remove duplication. See below:

drwxr-xr-x 1 durdle durdle 18 Jan 9 10:20 Are You Being Served -
drwxr-xr-x 1 durdle durdle 36 Jan 9 10:20 bates motel
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:20 Bates Motel
drwxr-xr-x 1 durdle durdle 108 Jan 9 10:21 cops
drwxr-xr-x 1 durdle durdle 126 Jan 9 10:21 Cops
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:19 Corner Gas
drwxr-xr-x 1 durdle durdle 36 Jan 9 10:19 Corner Gas -
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:19 CSI Miami
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:17 Discovery Channel How Its Made
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:20 downton abbey
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:20 Downton Abbey
drwxr-xr-x 1 durdle durdle 36 Jan 9 10:21 DuckTales -
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:19 Game of Thrones
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:20 Growing Pains
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:20 growing pains us
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:17 How Stuff Works
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:21 MasterChef New Zealand
drwxr-xr-x 1 durdle durdle 108 Jan 9 10:20 Mayday -
drwxr-xr-x 1 durdle durdle 64 Jan 9 10:21 Night Court -
drwxr-xr-x 1 durdle durdle 112 Jan 9 10:19 Roseanne -
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:19 terminator the sarah connor chronicles
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:19 Terminator The Sarah Connor Chronicles
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:19 The Apprentice UK -
drwxr-xr-x 1 durdle durdle 36 Jan 9 10:19 The Big Bang Theory
drwxr-xr-x 1 durdle durdle 54 Jan 9 10:19 TheLiquidator
drwxr-xr-x 1 durdle durdle 80 Jan 9 10:20 The Raccoons -
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:19 The Walking Dead
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:19 the war at home
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:19 The War at Home
drwxr-xr-x 1 durdle durdle 36 Jan 9 10:19 The War At Home
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:18 the wire
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:18 The Wire
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:18 The Wire -
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:20 Under the Dome
drwxr-xr-x 1 durdle durdle 96 Jan 9 10:20 Wonder Years
drwxr-xr-x 1 durdle durdle 16 Jan 9 10:18 X-files
drwxr-xr-x 1 durdle durdle 144 Jan 9 10:18 X-Files
drwxr-xr-x 1 durdle durdle 18 Jan 9 10:20 Young Apprentice

commented

Well if the module is good enough it could make it to the main repository and would auto install as a dependency. This lib would also allow for some clean renaming of what was scraped from Hive.
I tried to make it work but it had other lib dependencies as well and I threw the towel pretty fast, not enough of a priority :)

What I did for the upper case is still change the name to uppercase for the regexp, but use the title() function when building the folder path:

pathLib = self.addon.getSetting('tvshows_path') + '/' + show.title()

But I really like your 00x00 regexp additions and will modify my own code with it ^^