def test_should_extract_path_parts(self):
        paths = files.find_all_files(os.path.join(self.base_path, "Some.Movie.Archive"))
        paths = [p for p in paths]

        path = paths[0]
        path_parts = path.get_handler().file.get_path_parts()

        self.failUnlessEqual(3, len(path_parts), "Was NOT three")
        self.failUnlessEqual(["Some.Random.Movie.Sequel", "mapsm2.avi", "Some.Movie.Archive"], path_parts, path_parts)

        pretty_path = path.get_handler().file.get_pretty_path()

        self.failUnless(pretty_path.startswith(settings.FOLDERS_MOVIES))

        movie_folder_name = pretty_path.replace(settings.FOLDERS_MOVIES, "")

        self.failUnlessEqual("Some Random Movie Sequel", movie_folder_name.strip("/"))

        path = paths[1]
        path_parts = path.get_handler().file.get_path_parts()

        self.failUnlessEqual(3, len(path_parts), "Was NOT three")
        self.failUnlessEqual(["Some.Random.Movie", "mapsm.avi", "Some.Movie.Archive"], path_parts, path_parts)

        pretty_path = path.get_handler().file.get_pretty_path()

        self.failUnless(pretty_path.startswith(settings.FOLDERS_MOVIES))

        movie_folder_name = pretty_path.replace(settings.FOLDERS_MOVIES, "")

        self.failUnlessEqual("Some Random Movie", movie_folder_name.strip("/"))
Exemple #2
0
    def testRunOnEntireTestFolder(self):
        for execute_path in os.listdir(self.base_path):
            print '#' * 50
            print "# Working with dir: ", execute_path
            paths = files.find_all_files(os.path.join(self.base_path, execute_path))
            for pa in paths:
                print "#", pa.is_interesting(), '|', pa
                if pa.is_interesting():
                    pa.get_handler().execute()

                d = directory.get_dir(dir_name = execute_path)
                # If the directory is not in the database
                if not d:
                    d = directory.create_directory(
                       dir_name = execute_path,
                       path_name = self.base_path,
                       checked = datetime.now()
                    )
                    # Brand spanking new
                else:
                    if d.is_old():
                        print 'Dir is old'
                        continue

                print "#", pa.get_descriptive_string()
Exemple #3
0
    def test_should_work_with_movie_packs(self):
        for path in files.find_all_files(os.path.join(self.base_path, 'Some.Movie.Archive')):
            print path
            path_parts = path.get_handler().file.get_path_parts()



            if path.is_interesting():
                print "Pretty Path", path.get_handler().file.get_pretty_path()
Exemple #4
0
    def test_get_normal_names(self):
        for path in files.find_all_files(os.path.join(self.base_path, 'Simon_And_Garfunkel-Bridge_Over_Troubled_Water-(40th Anniversary_Edition)-2CD-2011-C4')):
            path_parts = path.get_handler().file.get_path_parts()
            print path_parts
            file = path.get_handler().file

            print file.get_analyzer()

            print "pretty path", file.get_pretty_path()
    def test_remove_watermarks(self):
        s = "Toddlers.and.Tiaras.S03E01.Le.Maison.de.Paris.HDTV.XviD-MOMENTUM [NO-RAR] - [ www.torrentday.com ]"

        paths = files.find_all_files(os.path.join(self.base_path, s))
        path = [p for p in paths][0]

        pretty_path = path.get_handler().file.get_pretty_path()

        self.failUnless(1 > pretty_path.find("torrentday"), pretty_path)
        self.failUnless(1 > pretty_path.lower().find("NO-RAR"))
Exemple #6
0
    def test_extract_from_id3(self):
        name = 'Freestylers - Pressure Point'
        for path in files.find_all_files(os.path.join(self.base_path, name)):
            path_parts = path.get_handler().file.get_path_parts()

            file_handler = path.get_handler().file
            
            if path.is_interesting():
                self.failUnlessEqual(
                    path.get_handler().file.get_pretty_path(),
                    os.path.join('/media/arnie/media/music', 'Freestylers', 'Pressure Point') + '/'
                )
Exemple #7
0
 def testUnrarMovie(self):
     for path in files.find_all_files(os.path.join(self.base_path, 'Big.Buck.Bunny')):
         if path.is_interesting():
             path.get_handler().execute()
Exemple #8
0
 def testExtractWeirdShowName(self):
     for path in files.find_all_files(os.path.join(self.base_path, 'Nile City 105.6')):
         if path.is_interesting():
             path.get_handler().execute()
        torrent_count += 1
        if not t.is_done:
            print('Waiting for item to finish: ', t.name)
            continue

        if not tracker.is_item_new(t.name):
            continue

        if not os.path.exists(t.path):
            print('Did not exist on local filesystem, ignoring.', t.name, t.path)
            continue

        print 'YAY new'
        print t.id

        for f in find_all_files(t.path):
            if not f.is_interesting():
                continue
            
            if not tracker.is_item_new(f.path):
                continue
            
            print 'I like!', f

            # We do not want to fill up the disk for nothing now do we?
            if FileFinder(options.output_path).files_count() >= options.unpacked_files_count:
                print 'Files in the output_path, waiting for them to be removed'
                exit("Files in out put path")

            handler = f.get_handler()
            handler.execute()
Exemple #10
0
        print 'Removing old directory: ', e
        try:
            shutil.rmtree(e.path)
        except OSError:
            # Already removed
            pass


#remove_old_output_directories(options.remove_old_output_compare_file,1)
#exit()

while True:
    for new_item in directory_watcher.get_new_items_in_directory():
        print 'NEW item;', new_item

        for f in find_all_files(new_item.full_path):
            if not f.is_interesting():
                continue

            print 'I like!', f

            # We do not want to fill up the disk for nothing now do we?
            while FileFinder(options.output_path).files_count() >= options.unpacked_files_count:
                print 'Files in the output_path, waiting for them to be removed'
                sleep(120)

                # Remove old directories
                remove_old_output_directories(
                    options.remove_old_output_compare_file,
                    300  # Five hours
                )
Exemple #11
0
        # If we should not delete the source after action
        # OR
        # the directory is not OLD
        if not settings.DELETE_SOURCE_AFTER_ACTION:
            if settings.VERBOSE:
                print 'We should not delete the soruce after action'
            continue
        
        if not d.is_old():
            if settings.VERBOSE:
                print 'The directory is NOT old, aborting.'
            continue

    # we should take action
    if take_action:
        for path in files.find_all_files(execute_path):
            handler = None
            if path.is_interesting():
                print "Is interesting", path
                handler = path.get_handler()
                print handler
                success = handler.execute()
                results.append(success)
    else:
        if settings.VERBOSE:
            print 'Did NOT take action'

    if False not in results and settings.DELETE_SOURCE_AFTER_ACTION or d.is_old():
        print 'REMOVING', execute_path
        files.removeall(execute_path)
        if os.path.isfile(execute_path):
Exemple #12
0
 def test_should_get_artist_folder(self):
     for path in files.find_all_files(os.path.join(self.base_path, 'Radiohead-The_King_Of_Limbs-(Retail)-2012-CR')):
         path_parts = path.get_handler().file.get_path_parts()
         if path.is_interesting():
             path.get_handler().file.get_pretty_path()
Exemple #13
0
 def testUnrarRarFile(self):
    for path in files.find_all_files(os.path.join(self.base_path, 'Real.RAR.s04e01')):
       if path.is_interesting():
          path.get_handler().execute()
Exemple #14
0
 def testAlias(self):
    for path in files.find_all_files(os.path.join(self.base_path, 'Alias')):
       if path.is_interesting():
          path.get_handler().execute()