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)
Example #2
0
def get_data(file):
    data = {}
    data["address"] = file
    file_name = simple_normalize(file.split("/")[-1])
    now = datetime.datetime.now()
    data["year"] = ""
    data["name"] = file_name

    try:
        if int(file_name.split()[-1]) > 1800 and int(file_name.split()[-1]) < now.year:
            data["year"] = file_name.split()[-1]
            data["name"] = file_name.replace(data["year"], "")
    except:
        data["year"] = ""
        data["name"] = file_name
    if data["name"] == "sample":
        return

    url = "http://www.omdbapi.com/?t=%s&y=%s" % (data["name"], data["year"])
    response = requests.get(url)
    res = response.json()
    if res["Response"] == "False":
        res = search_move(data["name"])
    res["name"] = data["name"]
    to_db(res)