Ejemplo n.º 1
0
def main():
    conn, cur = check_and_setup()
    if len(sys.argv) == 1:
        # no args, use curdir
        target_files = None
    else:
        target_files = sys.argv[1:]

    if (target_files is None):
        # use cwd as target_files
        files_with_data, files_wo_data = process_dir(u'.', conn, cur)
    else:
        files_with_data = []
        files_wo_data = []

        #target_files should be in cwd
        #make all target_files non_absolute
        for i in range(len(target_files)):
            target_files[i] = unicode(os.path.basename(target_files[i]), 'utf-8')

        for fil in target_files:
            if os.path.isdir(fil):
                f_with, f_wo = process_dir(fil, conn, cur)
                files_with_data.extend(f_with)
                files_wo_data.extend(f_wo)
            else:
                if is_movie_file(fil):
                    if is_in_db(conn, cur, fil):
                        files_with_data.append(fil)
                    else:
                        files_wo_data.append(fil)

    print 'files_with_data', files_with_data
    print 'files_wo_data', files_wo_data

    #spawn threads
    if (config.platform == 'windows' and config.config['debug']):
        app = wx.App(redirect=True)
    else:
        app = wx.App(redirect=False)

    if (not config.config['debug']):
        wx.Log_SetActiveTarget(wx.LogStderr())

    frame = MyFrame(None, conn, cur)

    check_for_updates(frame)

    app.SetTopWindow(frame)
    frame.Maximize()

    for f in files_with_data:
        frame.add_row(f)

    if len(files_wo_data) > 0:
        start_dbbuilder(frame, files_wo_data)

    frame.Show()
    frame.Layout()
    app.MainLoop()
Ejemplo n.º 2
0
def main():
	conn, cur = check_and_setup()
	res = []
	file_lst = []
	now = datetime.datetime.now()
	
	f = find('*', '/file/Backup/Download/film/')

	for item in f:
		if item.split('.')[-1] in config.movie_formats:
			file_name = simple_normalize(item.split('/')[-1])
			try:
				if int(file_name.split()[-1]) > 1800 and int(file_name.split()[-1]) < now.year:
					year = file_name.split()[-1]
					file_name = file_name.replace(year, '')
			except:
				pass
			if is_in_db(conn, cur, file_name, 'movies') or file_name == 'sample':
				pass
			else:
				file_lst.append(item)

	for item in Runner(file_lst):
		print item['name']
		add_to_db(item['name'], item, conn, cur)
Ejemplo n.º 3
0
def process_dir(directory, conn, cur):
    files_with_data = []
    files_wo_data = []

    for fil in os.listdir(directory):
        if os.path.isdir(os.path.join(directory, fil)):
            fil_children = os.listdir(os.path.join(directory, fil))
            for c in fil_children:
                if is_movie_file(c):
                    if is_in_db(conn, cur, c):
                        files_with_data.append(c)
                    else:
                        files_wo_data.append(c)
        else:
            if is_movie_file(fil):
                if is_in_db(conn, cur, fil):
                    files_with_data.append(fil)
                else:
                    files_wo_data.append(fil)
    return files_with_data, files_wo_data
Ejemplo n.º 4
0
def add_to_db(filename, file_data, conn, cur):
    args = [filename, file_data['Title'], file_data['Year'],
        file_data['Released'], file_data['Genre'], file_data['imdbRating'],
        file_data['Runtime'], file_data['Director'], file_data['Actors'],
        file_data['Plot'], file_data['Poster'], file_data['imdbID']]

    if (is_in_db(conn, cur, filename)):
        return

    cur.execute('INSERT INTO movies VALUES(?,?,?,?,?,?,?,?,?,?,?,?)',
            tuple(args))
    conn.commit()