Esempio n. 1
0
    def strm_file(self, i):
        try:
            name, title, year, imdb = i['name'], i['title'], i['year'], i['imdb']

            sysname, systitle = urllib.quote_plus(name), urllib.quote_plus(title)

            transname = name.translate(None, "\/:*?&'`<>|").strip('.')

            content = 'plugin://script.libra/?action=play&name=%s&title=%s&year=%s&imdb=%s' % (sysname, systitle, year, imdb)

            common.makeFile(self.library_folder)
            folder = os.path.join(self.library_folder, transname)
            if common.fileExists(folder + "/"):
                return False
            common.makeFile(folder)

            try:
                if not 'ftp://' in folder: raise Exception()
                from ftplib import FTP
                ftparg = re.compile('ftp://(.+?):(.+?)@(.+?):?(\d+)?/(.+/?)').findall(folder)
                ftp = FTP(ftparg[0][2],ftparg[0][0],ftparg[0][1])
                try: ftp.cwd(ftparg[0][4])
                except: ftp.mkd(ftparg[0][4])
                ftp.quit()
            except:
                pass

            stream = os.path.join(folder, transname + '.strm')
            strmfile = common.openFile(stream, 'w')
            strmfile.write(str(content))
            strmfile.close()

            nfo_stream = os.path.join(folder, transname + '.nfo')
            nfofile = common.openFile(nfo_stream, 'w')
            nfocontent = "http://www.imdb.com/title/%s" % imdb
            nfofile.write(str(nfocontent))
            nfofile.close()
        except:
            return False

        print "Create %s" % stream
        return True
Esempio n. 2
0
def movies_thread():
    while not xbmc.abortRequested:
        indicator = os.path.join(common.dataPath, 'settings.xml')
        if common.fileExists(indicator):
            MoviesThread().thread()
        xbmc.sleep(60000)