def rename(filename):
	filename_without_extension = filename
	extension = ""
	
	if os.path.isdir(filename) == False: 
		filename_without_extension, extension = os.path.splitext(filename)
	    
	query = ImdbQuery.create_query_from_filename(filename_without_extension)
	movie = Movie.create_movie_from_imdb_query(query)
	if movie.title == "None":
#		sys.stdout.write("Query Was: " + query + "\n")
		return "None"
		
	return unicode(movie).encode("utf-8") + extension
 def test_create_query_from_filename(self):
     from imdbquery_test_data import expected_query
     for filename in expected_query.keys():
         query = ImdbQuery.create_query_from_filename(filename)
         self.assertEqual(query, expected_query[filename])
 def test_exclude_terms(self):
     filename = ImdbQuery('Inception.DVDRiP.XviD-ARROW')
     terms_to_exclude = ('dvdrip', 'xvid', 'arrow')
     query = filename.lower().exclude_terms(terms_to_exclude)
     self.assertEqual(query, 'inception. . -')
 def test_remove_non_alphanumeric_chars(self):
     filename = ImdbQuery('Inception.2010.DVDRip.x264.dxva-TiMPE')
     query = filename.remove_non_alaphnumeric_chars()
     self.assertEqual(query, 'Inception 2010 DVDRip x264 dxva TiMPE')
 def test_add_parentheses_around_years(self):
     filename = ImdbQuery('Inception.2010.DVDRip.x264.dxva-TiMPE')
     query = filename.remove_non_alaphnumeric_chars(
     ).add_parentheses_around_years()
     self.assertEqual(query, 'Inception (2010) DVDRip x264 dxva TiMPE')
 def test_exclude_terms(self):
     filename = ImdbQuery('Inception.DVDRiP.XviD-ARROW')
     terms_to_exclude = ('dvdrip', 'xvid', 'arrow')
     query = filename.lower().exclude_terms(terms_to_exclude)
     self.assertEqual(query, 'inception. . -')
 def test_create_query_from_filename(self):
     from imdbquery_test_data import expected_query
     for filename in expected_query.keys():
         query = ImdbQuery.create_query_from_filename(filename)
         self.assertEqual(query, expected_query[filename])
 def test_add_parentheses_around_years(self):
     filename = ImdbQuery('Inception.2010.DVDRip.x264.dxva-TiMPE')
     query = filename.remove_non_alaphnumeric_chars().add_parentheses_around_years()
     self.assertEqual(query, 'Inception (2010) DVDRip x264 dxva TiMPE')
 def test_remove_non_alphanumeric_chars(self):
     filename = ImdbQuery('Inception.2010.DVDRip.x264.dxva-TiMPE')
     query = filename.remove_non_alaphnumeric_chars()
     self.assertEqual(query, 'Inception 2010 DVDRip x264 dxva TiMPE')
def rename(filename):
    filename_without_extension, extension = os.path.splitext(filename)
    query = ImdbQuery.create_query_from_filename(filename_without_extension)
    movie = Movie.create_movie_from_imdb_query(query)
    return str(movie) + extension