From 7ac88bb12829688f3256e772ca09047cb11d4793 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Mon, 26 Sep 2011 16:41:01 +0200 Subject: [PATCH 01/17] first commit --- README | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..e69de29 From c7e1f822d4c4910708b39180512bbd56dc3d20ef Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Tue, 27 Sep 2011 16:41:18 +0200 Subject: [PATCH 02/17] Delete a folder when a file is moved (use carefully, not fully tested yet) and adds some unittests to the project. --- .gitignore | 9 ++ CHANGES.txt | 0 LICENCE.txt | 0 MANIFEST.in | 2 + pigeonhole/__init__.py | 0 pigeonhole/config.py | 14 +++ pigeonhole/pigeonhole.py | 132 +++++++++++++++++++++++++++++ pigeonhole/test/__init__.py | 0 pigeonhole/test/test_pigeonhole.py | 76 +++++++++++++++++ setup.py | 15 ++++ 10 files changed, 248 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGES.txt create mode 100644 LICENCE.txt create mode 100644 MANIFEST.in create mode 100644 pigeonhole/__init__.py create mode 100644 pigeonhole/config.py create mode 100644 pigeonhole/pigeonhole.py create mode 100644 pigeonhole/test/__init__.py create mode 100644 pigeonhole/test/test_pigeonhole.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4d72aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +#python specific +*.pyc + +## generic files to ignore +*~ +*.lock +*.DS_Store +*.swp +*.out \ No newline at end of file diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 0000000..e69de29 diff --git a/LICENCE.txt b/LICENCE.txt new file mode 100644 index 0000000..e69de29 diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..9203697 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include *.txt +recursive-include docs *.txt \ No newline at end of file diff --git a/pigeonhole/__init__.py b/pigeonhole/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pigeonhole/config.py b/pigeonhole/config.py new file mode 100644 index 0000000..855e1a3 --- /dev/null +++ b/pigeonhole/config.py @@ -0,0 +1,14 @@ +# -*- coding: UTF8 -*- +# Configuration file + +### If a folder only contains these types of files, we can delete it. +useless_files_extensions = ('srr', 'nfo', 'sfv') + +### Consider only files with these extensions +shows_extensions = ('avi', 'mkv') + +### Dictionary for special filenames +shows_dict = { + 'white collar' : ['wc'], + 'the big bang theory' : ['tbbt'] +} \ No newline at end of file diff --git a/pigeonhole/pigeonhole.py b/pigeonhole/pigeonhole.py new file mode 100644 index 0000000..dc4fc7a --- /dev/null +++ b/pigeonhole/pigeonhole.py @@ -0,0 +1,132 @@ +#encoding: utf-8 + +import os +import re +import shutil +import filecmp +import config + +class Folder(object): + """ Directory show instanciation, relative to a path on the disk + ie. Show name + - Season 1 + - Season 2 + - ... + """ + + directory = None + name = None + + def __init__(self, path): + self.directory = path; + self.name = os.path.basename(self.directory) + + def __str__(self): + return self.name + ' [' + self.directory + ']' + +class Show(object): + """ Represents a show file; ie. a file associated to its fullname """ + + path = None + name = None + + def __init__(self, fullname, filename): + self.path = fullname + self.name = filename + + def __str__(self): + return self.name + + +class PigeonHole(object): + """ Takes all the media files in a (download) folder and sort + them into the corresponding folder, based on the found file name + """ + + directories = None + series = None + matches = None + + downloadDir = "" + rootShows = "" + + def __init__(self, root, downloaddir): + self.downloadDir = downloaddir + self.rootShows = root + self.directories = os.listdir(self.rootShows) + self.series = list() + + def walk(self): + """ Walks through the downloaded folders and yields .avi and .mkv files """ + for root, dirs, files in os.walk(self.downloadDir): + for filename in files: + if filename.endswith(config.shows_extensions): + yield Show(os.path.join(root, filename), filename) + + def walk(self, foldername, extensions): + for root, dirs, files in os.walk(foldername): + for filename in files: + if not filename.endswith(extensions): + yield os.path.join(root, filename) + + def process(self): + """ Parses the directories within the 'rootShows' folder and stores them as shows in a list. """ + self.series = [ Folder(os.path.join(self.rootShows, x)) for x in self.directories] + + for path in self.walk(config.shows_extensions): + self.moveToFolder(path) + + def moveToFolder(self, show): + """ Moves a specific show to its right folder. """ + + destinationfile = self.findFolder(show) + + if destinationfile is not None: + self.move(show.path, destinationfile) + + if self.isDeletable(show.path): + shutil.rmtree(show.path) + + def findFolder(self, show): + """Finds and returns the complete destinationpath for a specific show.""" + + rx = re.compile('\W+') + result = rx.sub(' ', show.name.lower()).strip() + + for s in self.series: + if s.name.lower() in result: + return os.path.join(s.directory, show.name) + + + def move(self, originalfile, destinationfile): + """ Moves the downloaded file to the found folder. """ + print "Moving " + show.name + " to " + destinationfile + shutil.move(originalfile, destinationfile) + + def isDeletable(self, foldername): + """ Walks through the current directory and deletes it if nothing's really important in it + ie. .nfo, .srr or .sfv files. + """ + if foldername is None: + return False + + if foldername == self.downloadDir or foldername == self.rootShows: + return False + + if self.downloadDir in foldername or self.rootShows in foldername: + return False + + if sum(1 for x in self.walk(foldername, config.useless_files_extensions)) is 0: + return True + + return False + + def __str__(self): + return 'PigeonHole module' + + def __name__(self): + return 'PigeonHole' + +if __name__ == "__main__": + pHole = PigeonHole(r'C:\test', r'C:\temp') + pHole.process() diff --git a/pigeonhole/test/__init__.py b/pigeonhole/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pigeonhole/test/test_pigeonhole.py b/pigeonhole/test/test_pigeonhole.py new file mode 100644 index 0000000..dcdf324 --- /dev/null +++ b/pigeonhole/test/test_pigeonhole.py @@ -0,0 +1,76 @@ +import random +import unittest +import tempfile +import shutil +import os +from pigeonhole import PigeonHole +import config + +class TestPigeonHoleFunctions(unittest.TestCase): + """Test the methods defined inside the PigeonHole class""" + + def setUp(self): + """Set up the test environment""" + self.rootdir = tempfile.mkdtemp(prefix='pigeonHole_root_') + self.downloaddir = tempfile.mkdtemp(prefix='pigeonHole_dl_dir_') + + # Create an environment with three folders + os.mkdir(os.path.join(self.rootdir, 'White Collar')) + os.mkdir(os.path.join(self.rootdir, 'The Big Bang Theory')) + os.mkdir(os.path.join(self.rootdir, 'Being Erica')) + + self.pigeonHole = PigeonHole(self.rootdir, self.downloaddir) + + self.notDeletableTmpDir = tempfile.mkdtemp(prefix='pigeonHole_') + self.deletableTmpDir = tempfile.mkdtemp(prefix='pigeonHole_') + + def tearDown(self): + """Tear down the test environment""" + self.pigeonHole = None + + shutil.rmtree(self.notDeletableTmpDir) + shutil.rmtree(self.deletableTmpDir) + + shutil.rmtree(self.rootdir) + shutil.rmtree(self.downloaddir) + + + def test_init(self): + """ Testing the constructor """ + self.assertEqual(self.pigeonHole.rootShows, self.rootdir) + self.assertEqual(self.pigeonHole.downloadDir, self.downloaddir) + self.assertTrue(str(self.pigeonHole) == 'PigeonHole module', 'The module string is not correct.') + self.assertTrue(str(self.pigeonHole.__name__ == 'PigeonHole'), 'The module name is not correct.') + + def test_clean(self): + """Testing the cleaning method""" + + self.generatedfiles_bad = list() + self.generatedfiles_good = list() + + for x in config.useless_files_extensions + config.shows_extensions: + fd, temppath = tempfile.mkstemp(x, 'tmp', self.notDeletableTmpDir) + self.generatedfiles_bad.append(temppath) + os.close(fd) + + for y in config.useless_files_extensions: + fd, temppath = tempfile.mkstemp(y, 'tmp', self.deletableTmpDir) + self.generatedfiles_good.append(temppath) + os.close(fd) + + self.assertFalse(self.pigeonHole.isDeletable(self.notDeletableTmpDir)) + self.assertTrue(self.pigeonHole.isDeletable(self.deletableTmpDir)) + + self.assertFalse(self.pigeonHole.isDeletable(self.rootdir)) + self.assertFalse(self.pigeonHole.isDeletable(self.downloaddir)) + + def test_findFolder(self): + """Try to move a file to a specific location""" + + + + + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7c94f6b --- /dev/null +++ b/setup.py @@ -0,0 +1,15 @@ +from distutils.core import setup + +setup { + name='PigeonHole', + version='0.1.0', + author='Fred Pauchet' + author_email='fpauchet@gmail.com', + packages=['pigeonhole','pigeonhole.test'], + scripts=[], + url='', + licence='LICENCE.txt', + description='', + long_description=long_description=open('README.txt').read(), + install_require=[], +} \ No newline at end of file From 63d737a02e174ca586aac45832c36b3aeb42aff9 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Tue, 27 Sep 2011 17:01:27 +0200 Subject: [PATCH 03/17] Change the filename of CHANGES and LICENCE --- CHANGES | 0 LICENCE | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 CHANGES create mode 100644 LICENCE diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..e69de29 diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..e69de29 From 9d0afafa80f44d8b90f02aea44926cdaecc4847b Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Tue, 27 Sep 2011 19:08:15 +0200 Subject: [PATCH 04/17] Delete two useless files --- CHANGES.txt | 0 LICENCE.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 CHANGES.txt delete mode 100644 LICENCE.txt diff --git a/CHANGES.txt b/CHANGES.txt deleted file mode 100644 index e69de29..0000000 diff --git a/LICENCE.txt b/LICENCE.txt deleted file mode 100644 index e69de29..0000000 From 96efba1d54c4042d970f234ef5cba536db114407 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Tue, 27 Sep 2011 22:36:14 +0200 Subject: [PATCH 05/17] Correcting a line in the setup.py file so it takes CHANGE and LICENCE file again, and adds a 'pass' statement in unit testing so it succeeded :p --- pigeonhole/test/test_pigeonhole.py | 4 ++-- setup.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pigeonhole/test/test_pigeonhole.py b/pigeonhole/test/test_pigeonhole.py index dcdf324..c215253 100644 --- a/pigeonhole/test/test_pigeonhole.py +++ b/pigeonhole/test/test_pigeonhole.py @@ -67,10 +67,10 @@ class TestPigeonHoleFunctions(unittest.TestCase): def test_findFolder(self): """Try to move a file to a specific location""" - + pass if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/setup.py b/setup.py index 7c94f6b..63de899 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,8 @@ setup { packages=['pigeonhole','pigeonhole.test'], scripts=[], url='', - licence='LICENCE.txt', + licence='LICENCE', description='', - long_description=long_description=open('README.txt').read(), + long_description=long_description=open('README').read(), install_require=[], -} \ No newline at end of file +} From f9449896460a02b9984c62a11a5fb0bd020cb57f Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Thu, 29 Sep 2011 17:50:32 +0200 Subject: [PATCH 06/17] Adding a dictionary inside the config file for special names --- pigeonhole/config.py | 5 +++-- pigeonhole/pigeonhole.py | 15 +++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pigeonhole/config.py b/pigeonhole/config.py index 855e1a3..fe3d08b 100644 --- a/pigeonhole/config.py +++ b/pigeonhole/config.py @@ -9,6 +9,7 @@ shows_extensions = ('avi', 'mkv') ### Dictionary for special filenames shows_dict = { - 'white collar' : ['wc'], - 'the big bang theory' : ['tbbt'] + 'wc' : 'white collar', + 'tbbt' : 'the big bang theory', + 'beingerica' : 'being erica', } \ No newline at end of file diff --git a/pigeonhole/pigeonhole.py b/pigeonhole/pigeonhole.py index dc4fc7a..f2d10c1 100644 --- a/pigeonhole/pigeonhole.py +++ b/pigeonhole/pigeonhole.py @@ -63,7 +63,7 @@ class PigeonHole(object): if filename.endswith(config.shows_extensions): yield Show(os.path.join(root, filename), filename) - def walk(self, foldername, extensions): + def walk2(self, foldername, extensions): for root, dirs, files in os.walk(foldername): for filename in files: if not filename.endswith(extensions): @@ -73,7 +73,7 @@ class PigeonHole(object): """ Parses the directories within the 'rootShows' folder and stores them as shows in a list. """ self.series = [ Folder(os.path.join(self.rootShows, x)) for x in self.directories] - for path in self.walk(config.shows_extensions): + for path in self.walk(): self.moveToFolder(path) def moveToFolder(self, show): @@ -86,6 +86,13 @@ class PigeonHole(object): if self.isDeletable(show.path): shutil.rmtree(show.path) + else: + for key in config.shows_dict: + if key.lower() in show.name.lower(): + if os.path.exists(os.path.join(self.rootShows, config.shows_dict[key])): + destinationfile = os.path.join(self.rootShows, config.shows_dict[key], show.name) + print destinationfile + self.move(show.path, destinationfile) def findFolder(self, show): """Finds and returns the complete destinationpath for a specific show.""" @@ -100,7 +107,7 @@ class PigeonHole(object): def move(self, originalfile, destinationfile): """ Moves the downloaded file to the found folder. """ - print "Moving " + show.name + " to " + destinationfile + print "Moving " + originalfile + " to " + destinationfile shutil.move(originalfile, destinationfile) def isDeletable(self, foldername): @@ -116,7 +123,7 @@ class PigeonHole(object): if self.downloadDir in foldername or self.rootShows in foldername: return False - if sum(1 for x in self.walk(foldername, config.useless_files_extensions)) is 0: + if sum(1 for x in self.walk2(foldername, config.useless_files_extensions)) is 0: return True return False From dd6aac029ee13b9bd325e44f1f65a32ffd87cd3e Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Thu, 29 Sep 2011 21:38:42 +0200 Subject: [PATCH 07/17] Corrects a bug when deleting the dl folder. Being a little more verbose. Correcting a little bug with the config file. --- pigeonhole/config.py | 2 +- pigeonhole/pigeonhole.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pigeonhole/config.py b/pigeonhole/config.py index fe3d08b..5e32b3f 100644 --- a/pigeonhole/config.py +++ b/pigeonhole/config.py @@ -7,7 +7,7 @@ useless_files_extensions = ('srr', 'nfo', 'sfv') ### Consider only files with these extensions shows_extensions = ('avi', 'mkv') -### Dictionary for special filenames +### Dictionary for special filename contents shows_dict = { 'wc' : 'white collar', 'tbbt' : 'the big bang theory', diff --git a/pigeonhole/pigeonhole.py b/pigeonhole/pigeonhole.py index f2d10c1..20b6efa 100644 --- a/pigeonhole/pigeonhole.py +++ b/pigeonhole/pigeonhole.py @@ -29,10 +29,12 @@ class Show(object): path = None name = None + directory = None def __init__(self, fullname, filename): self.path = fullname self.name = filename + self.directory = os.path.dirname(self.path) def __str__(self): return self.name @@ -84,8 +86,10 @@ class PigeonHole(object): if destinationfile is not None: self.move(show.path, destinationfile) - if self.isDeletable(show.path): - shutil.rmtree(show.path) + if self.isDeletable(show.directory): + print '\tDeleting ' + show.directory + shutil.rmtree(show.directory) + else: for key in config.shows_dict: if key.lower() in show.name.lower(): @@ -107,7 +111,7 @@ class PigeonHole(object): def move(self, originalfile, destinationfile): """ Moves the downloaded file to the found folder. """ - print "Moving " + originalfile + " to " + destinationfile + print 'Moving ' + originalfile + ' to ' + destinationfile shutil.move(originalfile, destinationfile) def isDeletable(self, foldername): @@ -120,9 +124,11 @@ class PigeonHole(object): if foldername == self.downloadDir or foldername == self.rootShows: return False - if self.downloadDir in foldername or self.rootShows in foldername: + if foldername in self.downloadDir or foldername in self.rootShows: return False + print 'I got ' + str(sum(1 for x in self.walk2(foldername, config.useless_files_extensions))) + ' int. files' + if sum(1 for x in self.walk2(foldername, config.useless_files_extensions)) is 0: return True From 18733e69d9a15045bd867cf0d00c8382a26801c7 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Thu, 29 Sep 2011 22:00:46 +0200 Subject: [PATCH 08/17] Readme --- README | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README b/README index e69de29..87c3af1 100644 --- a/README +++ b/README @@ -0,0 +1,29 @@ +PigeonHole +========== + +The main purpose of this application is to sort some specific types of files into a well-arranged directory. + +I used it for classifying tv shows from a garbage folder into the right one, based on the filename which will be cleaned to help sorting. + +How it works +------------ + +The project is splitted into several files : +* pigeonhole/pigeonhole.py : the one that should be run :) +* setup.py : not used yet (sorry) +* pigeonhole/config.py : where you should put your configuration. + +### config.py ### +The configuration file contains the declaration of three variables : +1. useless_files_extensions : used to clean a folder when the content of this directory (and its subdirectories) is only composed by this kind of files. Do not try to put `*` inside this filter, I don't know the behavior yet... +2. shows_extensions : the files that need to be organized. The `process` method of the `PigeonHole` class won't look for anything else than these filetype (sorry to based the recognition on extensions and not on [http://en.wikipedia.org/wiki/List_of_file_signatures](magic numbers)) +3. shows_dict : used for file that have a 'special name' +(ie. using 'tbbt' while the real name is much much longer) +Unit testing +------------ + +All tests are located inside the `pigeonhole/tests` directory. To launch them, use the following command, based on the python handbook: + + python -m unittest discover + +Temporary files and folders are created (and cleaned) to verify that the behavior is going okay. \ No newline at end of file From e125bbc02bfd605fcd3c75242ea59d7d3b156292 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Fri, 30 Sep 2011 08:18:24 +0200 Subject: [PATCH 09/17] readme --- README => README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) rename README => README.md (82%) diff --git a/README b/README.md similarity index 82% rename from README rename to README.md index 87c3af1..b1ef63e 100644 --- a/README +++ b/README.md @@ -10,15 +10,18 @@ How it works The project is splitted into several files : * pigeonhole/pigeonhole.py : the one that should be run :) -* setup.py : not used yet (sorry) +* setup.py : not used yet, sorry. * pigeonhole/config.py : where you should put your configuration. ### config.py ### + The configuration file contains the declaration of three variables : + 1. useless_files_extensions : used to clean a folder when the content of this directory (and its subdirectories) is only composed by this kind of files. Do not try to put `*` inside this filter, I don't know the behavior yet... -2. shows_extensions : the files that need to be organized. The `process` method of the `PigeonHole` class won't look for anything else than these filetype (sorry to based the recognition on extensions and not on [http://en.wikipedia.org/wiki/List_of_file_signatures](magic numbers)) +2. shows_extensions : the files that need to be organized. The `process` method of the `PigeonHole` class won't look for anything else than these filetype (sorry to based the recognition on extensions and not on [magic numbers](http://en.wikipedia.org/wiki/List_of_file_signatures)) 3. shows_dict : used for file that have a 'special name' -(ie. using 'tbbt' while the real name is much much longer) +(ie. using 'tbbt' while the real name that can be found in the destination folder is much much longer) + Unit testing ------------ @@ -26,4 +29,4 @@ All tests are located inside the `pigeonhole/tests` directory. To launch them, u python -m unittest discover -Temporary files and folders are created (and cleaned) to verify that the behavior is going okay. \ No newline at end of file +Temporary files and folders are created (and cleaned) to verify that the file behavior is going okay. \ No newline at end of file From dbbcb311543d674f7dd19a51d01f91f9aea395e2 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Tue, 4 Oct 2011 09:04:37 +0200 Subject: [PATCH 10/17] tvsubtitles query --- README | 32 ++++++++++++++++++++++++++++++++ pigeonhole/subQuery.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 README create mode 100644 pigeonhole/subQuery.py diff --git a/README b/README new file mode 100644 index 0000000..79ea1b9 --- /dev/null +++ b/README @@ -0,0 +1,32 @@ +PigeonHole +========== + +The main purpose of this application is to sort some specific types of files into a well-arranged directory. + +I used it for classifying tv shows from a garbage folder into the right one, based on the filename which will be cleaned to help sorting. + +How it works +------------ + +The project is splitted into several files : +* pigeonhole/pigeonhole.py : the one that should be run :) +* setup.py : not used yet, sorry. +* pigeonhole/config.py : where you should put your configuration. + +### config.py ### + +The configuration file contains the declaration of three variables : + +1. useless_files_extensions : used to clean a folder when the content of this directory (and its subdirectories) is only composed by this kind of files. Do not try to put `*` inside this filter, I don't know the behavior yet... +2. shows_extensions : the files that need to be organized. The `process` method of the `PigeonHole` class won't look for anything else than these filetype, based the recognition of extensions and not on [magic numbers](http://en.wikipedia.org/wiki/List_of_file_signatures). +3. shows_dict : used for file that have a 'special name' +(ie. using 'tbbt' while the real name that can be found in the destination folder is much much longer) + +Unit testing +------------ + +All tests are located inside the `pigeonhole/tests` directory. To launch them, use the following command, based on the python handbook: + + python -m unittest discover + +Temporary files and folders are created (and cleaned) to verify that the file behavior is going okay. \ No newline at end of file diff --git a/pigeonhole/subQuery.py b/pigeonhole/subQuery.py new file mode 100644 index 0000000..0500b58 --- /dev/null +++ b/pigeonhole/subQuery.py @@ -0,0 +1,32 @@ +import urllib2 +import re +from BeautifulSoup import BeautifulSoup + +""" + Querying non web services through http interrogation and regex results retrieval. +""" + +def query(showname): + print "Trying " + showname + socket = urllib2.urlopen('http://www.tvsubtitles.net/search.php?q=' + showname.replace(' ', '%20')) + soup = BeautifulSoup(socket.read()) + socket.close() + + results = soup.findAll(href=re.compile("/tvshow-([A-Za-z0-9]*)\.html$")) + + if len(results) == 1: + "ouh yeah baby " + showname + " " + str(results[0]) + + elif len(results) == 0: + print "No results found for " + showname + else: + print "Here are the possible results for " + showname + for res in results: + print "\t" + str(res) + +if __name__ == "__main__": + query('the big bang theory') + query('being erica') + query('white collar') + query('scrubs') + query('castle') \ No newline at end of file From 2cc271f0978580ed0e999a4a4d119e67b0e39929 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Tue, 4 Oct 2011 17:26:36 +0200 Subject: [PATCH 11/17] querying non ws interfaces through http and regex results retrieval --- pigeonhole/subQuery.py | 44 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/pigeonhole/subQuery.py b/pigeonhole/subQuery.py index 0500b58..aaaae39 100644 --- a/pigeonhole/subQuery.py +++ b/pigeonhole/subQuery.py @@ -3,9 +3,15 @@ import re from BeautifulSoup import BeautifulSoup """ - Querying non web services through http interrogation and regex results retrieval. + Querying non web services interfaces + through http interrogation and regex results retrieval. """ +languages = ('en', 'es', 'fr', 'de') + +def queryUrl(baseurl, baseregex): + print 'Querying %s w/ %s' % baseurl, baseregex + def query(showname): print "Trying " + showname socket = urllib2.urlopen('http://www.tvsubtitles.net/search.php?q=' + showname.replace(' ', '%20')) @@ -14,15 +20,49 @@ def query(showname): results = soup.findAll(href=re.compile("/tvshow-([A-Za-z0-9]*)\.html$")) + + # a yield here would be cool ! :) if len(results) == 1: - "ouh yeah baby " + showname + " " + str(results[0]) + print str(results[0]) + return results[0] elif len(results) == 0: print "No results found for " + showname + return None else: print "Here are the possible results for " + showname for res in results: print "\t" + str(res) + return None + + +def getSeason(showname, seasonNumber): + season = query(showname) + + #idem + + if season is not None: + print str(season).replace('.html', '-' + seasonNumber + '.html') + + else: + print "no season found" + +def getEpisode(showname, seasonNumber, episodeNumber): + season = query(showname, seasonNumber) + + urllib2.urlopen(season) + + + #idem + + if episode is not None: + print str(episode).replace('.html', '-') + else: + print "no episode found" + +def getUrl(showname, seasonNumber, episodeNumber, language): + """Supposed to send to the right page, according to the right episode number""" + pass if __name__ == "__main__": query('the big bang theory') From 638654066f7b93ba5c9cc5f4695cd637e67d38bd Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Wed, 5 Oct 2011 09:08:22 +0200 Subject: [PATCH 12/17] delete experimental files --- pigeonhole/subQuery.py | 72 ------------------------------------------ 1 file changed, 72 deletions(-) delete mode 100644 pigeonhole/subQuery.py diff --git a/pigeonhole/subQuery.py b/pigeonhole/subQuery.py deleted file mode 100644 index aaaae39..0000000 --- a/pigeonhole/subQuery.py +++ /dev/null @@ -1,72 +0,0 @@ -import urllib2 -import re -from BeautifulSoup import BeautifulSoup - -""" - Querying non web services interfaces - through http interrogation and regex results retrieval. -""" - -languages = ('en', 'es', 'fr', 'de') - -def queryUrl(baseurl, baseregex): - print 'Querying %s w/ %s' % baseurl, baseregex - -def query(showname): - print "Trying " + showname - socket = urllib2.urlopen('http://www.tvsubtitles.net/search.php?q=' + showname.replace(' ', '%20')) - soup = BeautifulSoup(socket.read()) - socket.close() - - results = soup.findAll(href=re.compile("/tvshow-([A-Za-z0-9]*)\.html$")) - - - # a yield here would be cool ! :) - if len(results) == 1: - print str(results[0]) - return results[0] - - elif len(results) == 0: - print "No results found for " + showname - return None - else: - print "Here are the possible results for " + showname - for res in results: - print "\t" + str(res) - return None - - -def getSeason(showname, seasonNumber): - season = query(showname) - - #idem - - if season is not None: - print str(season).replace('.html', '-' + seasonNumber + '.html') - - else: - print "no season found" - -def getEpisode(showname, seasonNumber, episodeNumber): - season = query(showname, seasonNumber) - - urllib2.urlopen(season) - - - #idem - - if episode is not None: - print str(episode).replace('.html', '-') - else: - print "no episode found" - -def getUrl(showname, seasonNumber, episodeNumber, language): - """Supposed to send to the right page, according to the right episode number""" - pass - -if __name__ == "__main__": - query('the big bang theory') - query('being erica') - query('white collar') - query('scrubs') - query('castle') \ No newline at end of file From 26cd5e67c304f96572dd776f62d76190cbdf7767 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Mon, 21 Nov 2011 21:21:31 +0100 Subject: [PATCH 13/17] adding subQuery.py methods to query html pages and retrieve specific urls. --- pigeonhole/subQuery.py | 109 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 pigeonhole/subQuery.py diff --git a/pigeonhole/subQuery.py b/pigeonhole/subQuery.py new file mode 100644 index 0000000..d8c1623 --- /dev/null +++ b/pigeonhole/subQuery.py @@ -0,0 +1,109 @@ +import urllib2 +import re +import os +from BeautifulSoup import BeautifulSoup + +""" + Querying non web services interfaces + through http interrogation and regex results retrieval. +""" + +languages = ('en', 'es', 'fr', 'de') + +def queryUrl(baseurl, baseregex): + print 'Querying %s w/ %s' % (baseurl, baseregex) + +def query(showname): + print "Trying " + showname + socket = urllib2.urlopen('http://www.tvsubtitles.net/search.php?q=' + showname.replace(' ', '%20')) + soup = BeautifulSoup(socket.read()) + socket.close() + + results = soup.findAll(href=re.compile("/tvshow-([A-Za-z0-9]*)\.html$")) + + + # a yield here would be cool ! :) + if len(results) == 1: + print str(results[0]) + return results[0] + + elif len(results) == 0: + print "No results found for " + showname + return None + else: + print "Here are the possible results for " + showname + for res in results: + print "\t" + str(res) + return None + +""" Get a specific season, based on the show name and the season number + + eg. getSeason('suits', 1) + getSeason('dexter', 3) +""" +def getSeason(showname, seasonNumber): + season = query(showname) + + #idem + + if season is not None: + print str(season).replace('.html', '-' + str(seasonNumber) + '.html') + + else: + print "no season found" + +""" Get a specific episode, based on the show name, the season number and the episode number + + eg. getEpisode('being erica', 2, 12) + getEpisode('the big bang theory', 3, 15) +""" +def getEpisode(showname, seasonNumber, episodeNumber): + + raise Exception('not implemented yet') + + season = query(showname, seasonNumber) + + urllib2.urlopen(season) + + + #idem + + if episode is not None: + print str(episode).replace('.html', '-') + else: + print "no episode found" + +def getUrl(showname, seasonNumber, episodeNumber, language): + """Supposed to send to the right page, according to the right episode number""" + pass + +""" Write a shortcut to a specific web page and fix the shortcutname within the writtent file. + + eg. writeUrlShortcut('/opt/tmp', 'google.url', 'http://www.google.com', 'Google') + >>> [Google] + >>> URL=http://www.google.com + >>> inside a file named /opt/tmp/google.url +""" +def writeUrlShortcut(folderpath, filename, url, shortcutname): + if not os.path.exists(folderpath): + raise Exception('Writing Url : Path does not exists') + + filecontent = """[%s]\nURL=%s""" % (shortcutname, url) + + with open(os.path.join(folderpath, filename), 'w+') as f: + f.write(filecontent) + + +if __name__ == "__main__": + #queryUrl('http://www.tvsubtitles.net/search?q=', 'tvshow') + + # query('the big bang theory') + # query('being erica') + # query('white collar') + # query('scrubs') + # query('castle') + + getSeason('the big bang theory', 2) + getSeason('white collar', 1) + getSeason('suits', 1) + getSeason('being erica', 2) \ No newline at end of file From f3b14d2516ca858700ef8a760eda77cc38886210 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Tue, 22 Nov 2011 21:37:47 +0100 Subject: [PATCH 14/17] Refactoring generic url querying Shortcut creation nearly running --- pigeonhole/subQuery.py | 56 ++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/pigeonhole/subQuery.py b/pigeonhole/subQuery.py index d8c1623..974ec16 100644 --- a/pigeonhole/subQuery.py +++ b/pigeonhole/subQuery.py @@ -10,21 +10,43 @@ from BeautifulSoup import BeautifulSoup languages = ('en', 'es', 'fr', 'de') -def queryUrl(baseurl, baseregex): - print 'Querying %s w/ %s' % (baseurl, baseregex) -def query(showname): - print "Trying " + showname - socket = urllib2.urlopen('http://www.tvsubtitles.net/search.php?q=' + showname.replace(' ', '%20')) +""" + Querying a base url with a specific regex and a query. + + eg. baseurl = http://duckduckgo.com/?q= + query = my_query + baseregex = ... :) + + It will query the url, adds the query string and will fetch every href link that match the regular expression. +""" +def queryUrl(baseurl, paramindicator, regex, querystring): + socket = urllib2.urlopen(baseurl + paramindicator + querystring) soup = BeautifulSoup(socket.read()) socket.close() - results = soup.findAll(href=re.compile("/tvshow-([A-Za-z0-9]*)\.html$")) + tags = soup.findAll(href=re.compile(regex)) + mylist = list() + + for tag in tags: + bsoup = BeautifulSoup(str(tag)) + mylist.append(baseurl + bsoup.a['href']) + + return mylist + +def queryShow(showname): + return queryUrl('http://www.tvsubtitles.net', '/search.php?q=', '/tvshow-([A-Za-z0-9]*)\.html$', showname.replace(' ', '%20')) + +def querySeason(showname, seasonnumber): + pass + +def query(showname): + results = queryShow(showname) # a yield here would be cool ! :) if len(results) == 1: - print str(results[0]) + print results[0] return results[0] elif len(results) == 0: @@ -59,7 +81,7 @@ def getSeason(showname, seasonNumber): """ def getEpisode(showname, seasonNumber, episodeNumber): - raise Exception('not implemented yet') + raise Exception('not yet implemented') season = query(showname, seasonNumber) @@ -73,8 +95,8 @@ def getEpisode(showname, seasonNumber, episodeNumber): else: print "no episode found" +"""Supposed to send to the right page, according to the right episode number""" def getUrl(showname, seasonNumber, episodeNumber, language): - """Supposed to send to the right page, according to the right episode number""" pass """ Write a shortcut to a specific web page and fix the shortcutname within the writtent file. @@ -93,6 +115,11 @@ def writeUrlShortcut(folderpath, filename, url, shortcutname): with open(os.path.join(folderpath, filename), 'w+') as f: f.write(filecontent) +def walk(foldername): + for root, dirs, files in os.walk(foldername): + for directory in dirs: + if query(directory) is not None: + yield directory if __name__ == "__main__": #queryUrl('http://www.tvsubtitles.net/search?q=', 'tvshow') @@ -103,7 +130,10 @@ if __name__ == "__main__": # query('scrubs') # query('castle') - getSeason('the big bang theory', 2) - getSeason('white collar', 1) - getSeason('suits', 1) - getSeason('being erica', 2) \ No newline at end of file + for match in walk(r'C:\Tmp'): + print match + + # getSeason('the big bang theory', 2) + # getSeason('white collar', 1) + # getSeason('suits', 1) + # getSeason('being erica', 2) \ No newline at end of file From b6ef8c14da47711a25185c71bd0c24ee4ace79e1 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Wed, 28 Dec 2011 16:10:02 +0100 Subject: [PATCH 15/17] changing model, adding subtitles query, building structure --- pigeonhole/model.py | 47 +++++++++++++++++ pigeonhole/pigeonhole.py | 17 +----- pigeonhole/subQuery.py | 110 +++++++++++++-------------------------- 3 files changed, 84 insertions(+), 90 deletions(-) create mode 100644 pigeonhole/model.py diff --git a/pigeonhole/model.py b/pigeonhole/model.py new file mode 100644 index 0000000..0722dd4 --- /dev/null +++ b/pigeonhole/model.py @@ -0,0 +1,47 @@ +from subQuery import * + +class Structure(object): + + def __init__(self): + print 'building myself' + +class Show(object): + """ Represents a show file; ie. a file associated to its fullname """ + + path = None + name = None + directory = None + + url = None + + Seasons = list() + + def append(self, season): + self.Seasons.append(season) + season.parent = self + + def __init__(self, fullname, filename): + self.path = fullname + self.name = filename + self.directory = os.path.dirname(self.path) + url = queryShow(self.name) + + def __str__(self): + return self.name + +class Season(object): + """ Represents a season within a show """ + + seasonnumber = None + parent = None + + def __init__(self, seasonnumber): + self.seasonnumber = seasonnumber + +class Episode(object): + """ Represents an episode within a season """ + + title = None + + def __init__(self, title): + self.title = title \ No newline at end of file diff --git a/pigeonhole/pigeonhole.py b/pigeonhole/pigeonhole.py index 20b6efa..4a27f3e 100644 --- a/pigeonhole/pigeonhole.py +++ b/pigeonhole/pigeonhole.py @@ -5,6 +5,7 @@ import re import shutil import filecmp import config +from model import Show class Folder(object): """ Directory show instanciation, relative to a path on the disk @@ -24,22 +25,6 @@ class Folder(object): def __str__(self): return self.name + ' [' + self.directory + ']' -class Show(object): - """ Represents a show file; ie. a file associated to its fullname """ - - path = None - name = None - directory = None - - def __init__(self, fullname, filename): - self.path = fullname - self.name = filename - self.directory = os.path.dirname(self.path) - - def __str__(self): - return self.name - - class PigeonHole(object): """ Takes all the media files in a (download) folder and sort them into the corresponding folder, based on the found file name diff --git a/pigeonhole/subQuery.py b/pigeonhole/subQuery.py index 974ec16..e3e035c 100644 --- a/pigeonhole/subQuery.py +++ b/pigeonhole/subQuery.py @@ -10,6 +10,26 @@ from BeautifulSoup import BeautifulSoup languages = ('en', 'es', 'fr', 'de') +""" not documented yet +""" +class CustomUrl(object): + fullUrl = None + suffix = None + base = None + + def __init__(self, base, suffix): + self.base = base + self.suffix = suffix + self.fullUrl = base + suffix + + def __str__(self): + return str(self.fullUrl) + + def __unicode__(self): + return str(self.fullUrl) + + def replace(self, oldstr, newstr): + return CustomUrl(self.base, self.suffix.replace(oldstr, newstr)) """ Querying a base url with a specific regex and a query. @@ -21,6 +41,7 @@ languages = ('en', 'es', 'fr', 'de') It will query the url, adds the query string and will fetch every href link that match the regular expression. """ def queryUrl(baseurl, paramindicator, regex, querystring): + #print '\tProbing ' + baseurl + ' ' + paramindicator + ' ' + regex + ' ' + querystring socket = urllib2.urlopen(baseurl + paramindicator + querystring) soup = BeautifulSoup(socket.read()) socket.close() @@ -31,7 +52,7 @@ def queryUrl(baseurl, paramindicator, regex, querystring): for tag in tags: bsoup = BeautifulSoup(str(tag)) - mylist.append(baseurl + bsoup.a['href']) + mylist.append(CustomUrl(baseurl, bsoup.a['href'])) return mylist @@ -39,65 +60,14 @@ def queryShow(showname): return queryUrl('http://www.tvsubtitles.net', '/search.php?q=', '/tvshow-([A-Za-z0-9]*)\.html$', showname.replace(' ', '%20')) def querySeason(showname, seasonnumber): + return [x.replace('.html', '-' + str(seasonnumber) + '.html') for x in queryShow(showname)] + + +"""Supposed to return the url, according to the show name and season number""" +def getUrl(showname, seasonNumber, episodenumber, language): + Raise("not implemented yet") pass -def query(showname): - results = queryShow(showname) - - # a yield here would be cool ! :) - if len(results) == 1: - print results[0] - return results[0] - - elif len(results) == 0: - print "No results found for " + showname - return None - else: - print "Here are the possible results for " + showname - for res in results: - print "\t" + str(res) - return None - -""" Get a specific season, based on the show name and the season number - - eg. getSeason('suits', 1) - getSeason('dexter', 3) -""" -def getSeason(showname, seasonNumber): - season = query(showname) - - #idem - - if season is not None: - print str(season).replace('.html', '-' + str(seasonNumber) + '.html') - - else: - print "no season found" - -""" Get a specific episode, based on the show name, the season number and the episode number - - eg. getEpisode('being erica', 2, 12) - getEpisode('the big bang theory', 3, 15) -""" -def getEpisode(showname, seasonNumber, episodeNumber): - - raise Exception('not yet implemented') - - season = query(showname, seasonNumber) - - urllib2.urlopen(season) - - - #idem - - if episode is not None: - print str(episode).replace('.html', '-') - else: - print "no episode found" - -"""Supposed to send to the right page, according to the right episode number""" -def getUrl(showname, seasonNumber, episodeNumber, language): - pass """ Write a shortcut to a specific web page and fix the shortcutname within the writtent file. @@ -118,22 +88,14 @@ def writeUrlShortcut(folderpath, filename, url, shortcutname): def walk(foldername): for root, dirs, files in os.walk(foldername): for directory in dirs: - if query(directory) is not None: - yield directory + + +def echo(var): + for x in var: + print x if __name__ == "__main__": - #queryUrl('http://www.tvsubtitles.net/search?q=', 'tvshow') + for x in walk(r'C:\temp'): + print x - # query('the big bang theory') - # query('being erica') - # query('white collar') - # query('scrubs') - # query('castle') - - for match in walk(r'C:\Tmp'): - print match - - # getSeason('the big bang theory', 2) - # getSeason('white collar', 1) - # getSeason('suits', 1) - # getSeason('being erica', 2) \ No newline at end of file + echo(queryShow('saison 1')) \ No newline at end of file From 55537c04e5a4d77f402b66202722c6045f6e908d Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Thu, 29 Dec 2011 15:58:09 +0100 Subject: [PATCH 16/17] url shortcurt writer seems to work --- pigeonhole/model.py | 87 ++++++++++++++++++++++-------- pigeonhole/pigeonhole.py | 29 +++------- pigeonhole/subQuery.py | 32 +++-------- pigeonhole/test/test_pigeonhole.py | 7 ++- setup.py | 26 ++++----- 5 files changed, 92 insertions(+), 89 deletions(-) diff --git a/pigeonhole/model.py b/pigeonhole/model.py index 0722dd4..7b90e4e 100644 --- a/pigeonhole/model.py +++ b/pigeonhole/model.py @@ -1,30 +1,28 @@ from subQuery import * +import os class Structure(object): + """Represents the complete structure, with its shows, seasons and episodes""" + + def __init__(self, path): + self.shows = [Show(os.path.join(path, x)) for x in os.listdir(path) if os.path.isdir(os.path.join(path, x))] - def __init__(self): - print 'building myself' + def writeUrls(self): + for s in self.shows: + for season in s.seasons: + season.writeUrl() class Show(object): """ Represents a show file; ie. a file associated to its fullname """ - - path = None - name = None - directory = None - url = None + def __init__(self, path): - Seasons = list() + self.path = path + self.name = os.path.basename(path) - def append(self, season): - self.Seasons.append(season) - season.parent = self + self.url = queryShow(self.name) - def __init__(self, fullname, filename): - self.path = fullname - self.name = filename - self.directory = os.path.dirname(self.path) - url = queryShow(self.name) + self.seasons = [Season(self, os.path.join(path, x)) for x in os.listdir(path) if os.path.isdir(os.path.join(path, x))] def __str__(self): return self.name @@ -32,16 +30,59 @@ class Show(object): class Season(object): """ Represents a season within a show """ - seasonnumber = None - parent = None + def __init__(self, parent, path): - def __init__(self, seasonnumber): - self.seasonnumber = seasonnumber + self.parent = parent + self.path = path + self.name = os.path.basename(path) + self.seasonnumber = re.findall('[0-9]+', os.path.basename(path))[0] + self.episodes = [Episode(self, os.path.join(path, x)) for x in os.listdir(path) if os.path.isfile(os.path.join(path, x))] + + self.url = querySeason(parent.name, self.seasonnumber) + + def writeUrl(self): + if len(self.url) == 1: + results = querySeason(self.parent.name, self.seasonnumber) + + if len(results) == 1: + print 'Writing subtitles shortcut for ' + self.parent.name + writeUrlShortcut(self.path, self.parent.name + '.url', str(self.url[0]), 'InternetShortcut') + elif len(results) == 0: + print 'no results have been found for ' + self.parent.name + else: + print 'too much results have been found' + elif len(self.url) == 0: + print 'too few urls for ' + self.parent.name + else: + print 'too many urls for ' + self.parent.name class Episode(object): """ Represents an episode within a season """ - title = None + def __init__(self, parent, path): + print 'Building an episode: ' + path - def __init__(self, title): - self.title = title \ No newline at end of file + self.parent = parent + self.path = path + self.name = os.path.basename(path) + + def __str__(self): + return self.name + +class Folder(object): + """ Directory show instanciation, relative to a path on the disk + ie. Show name + - Season 1 + - Season 2 + - ... + """ + + directory = None + name = None + + def __init__(self, path): + self.directory = path; + self.name = os.path.basename(self.directory) + + def __str__(self): + return self.name + ' [' + self.directory + ']' \ No newline at end of file diff --git a/pigeonhole/pigeonhole.py b/pigeonhole/pigeonhole.py index 4a27f3e..f1a619f 100644 --- a/pigeonhole/pigeonhole.py +++ b/pigeonhole/pigeonhole.py @@ -5,39 +5,20 @@ import re import shutil import filecmp import config -from model import Show -class Folder(object): - """ Directory show instanciation, relative to a path on the disk - ie. Show name - - Season 1 - - Season 2 - - ... - """ - - directory = None - name = None - - def __init__(self, path): - self.directory = path; - self.name = os.path.basename(self.directory) - - def __str__(self): - return self.name + ' [' + self.directory + ']' +from model import * class PigeonHole(object): """ Takes all the media files in a (download) folder and sort them into the corresponding folder, based on the found file name """ - directories = None - series = None matches = None - downloadDir = "" - rootShows = "" - def __init__(self, root, downloaddir): + + self.structure = Structure(root) + self.downloadDir = downloaddir self.rootShows = root self.directories = os.listdir(self.rootShows) @@ -128,3 +109,5 @@ class PigeonHole(object): if __name__ == "__main__": pHole = PigeonHole(r'C:\test', r'C:\temp') pHole.process() + pHole.structure.writeUrls() + diff --git a/pigeonhole/subQuery.py b/pigeonhole/subQuery.py index e3e035c..e0d206e 100644 --- a/pigeonhole/subQuery.py +++ b/pigeonhole/subQuery.py @@ -10,7 +10,9 @@ from BeautifulSoup import BeautifulSoup languages = ('en', 'es', 'fr', 'de') -""" not documented yet +""" + Represents a custom url object. + It refers to a simple web page and can be embedded anywhere. """ class CustomUrl(object): fullUrl = None @@ -18,9 +20,9 @@ class CustomUrl(object): base = None def __init__(self, base, suffix): - self.base = base - self.suffix = suffix - self.fullUrl = base + suffix + self.base = str(base) + self.suffix = str(suffix) + self.fullUrl = self.base + self.suffix def __str__(self): return str(self.fullUrl) @@ -62,13 +64,6 @@ def queryShow(showname): def querySeason(showname, seasonnumber): return [x.replace('.html', '-' + str(seasonnumber) + '.html') for x in queryShow(showname)] - -"""Supposed to return the url, according to the show name and season number""" -def getUrl(showname, seasonNumber, episodenumber, language): - Raise("not implemented yet") - pass - - """ Write a shortcut to a specific web page and fix the shortcutname within the writtent file. eg. writeUrlShortcut('/opt/tmp', 'google.url', 'http://www.google.com', 'Google') @@ -84,18 +79,3 @@ def writeUrlShortcut(folderpath, filename, url, shortcutname): with open(os.path.join(folderpath, filename), 'w+') as f: f.write(filecontent) - -def walk(foldername): - for root, dirs, files in os.walk(foldername): - for directory in dirs: - - -def echo(var): - for x in var: - print x - -if __name__ == "__main__": - for x in walk(r'C:\temp'): - print x - - echo(queryShow('saison 1')) \ No newline at end of file diff --git a/pigeonhole/test/test_pigeonhole.py b/pigeonhole/test/test_pigeonhole.py index c215253..41abbb4 100644 --- a/pigeonhole/test/test_pigeonhole.py +++ b/pigeonhole/test/test_pigeonhole.py @@ -1,10 +1,9 @@ -import random import unittest import tempfile import shutil import os -from pigeonhole import PigeonHole -import config +from pigeonhole import * +#import config class TestPigeonHoleFunctions(unittest.TestCase): """Test the methods defined inside the PigeonHole class""" @@ -19,7 +18,7 @@ class TestPigeonHoleFunctions(unittest.TestCase): os.mkdir(os.path.join(self.rootdir, 'The Big Bang Theory')) os.mkdir(os.path.join(self.rootdir, 'Being Erica')) - self.pigeonHole = PigeonHole(self.rootdir, self.downloaddir) + self.pigeonHole = pigeonhole.PigeonHole(self.rootdir, self.downloaddir) self.notDeletableTmpDir = tempfile.mkdtemp(prefix='pigeonHole_') self.deletableTmpDir = tempfile.mkdtemp(prefix='pigeonHole_') diff --git a/setup.py b/setup.py index 63de899..b982237 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,15 @@ from distutils.core import setup -setup { - name='PigeonHole', - version='0.1.0', - author='Fred Pauchet' - author_email='fpauchet@gmail.com', - packages=['pigeonhole','pigeonhole.test'], - scripts=[], - url='', - licence='LICENCE', - description='', - long_description=long_description=open('README').read(), - install_require=[], -} +#setup { +# name='PigeonHole', +# version='0.1.0', +# author='Fred Pauchet' +# author_email='fpauchet@gmail.com', +# packages=['pigeonhole','pigeonhole.test'], +# scripts=[], +# url='', +# licence='LICENCE', +# description='', +# long_description=long_description=open('README').read(), +# install_require=[], +#} From 2049acc7815b7a56550c29dccc2a898ab307cb80 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Thu, 29 Dec 2011 16:01:04 +0100 Subject: [PATCH 17/17] disable echo for building episode --- pigeonhole/model.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pigeonhole/model.py b/pigeonhole/model.py index 7b90e4e..a110176 100644 --- a/pigeonhole/model.py +++ b/pigeonhole/model.py @@ -60,8 +60,7 @@ class Episode(object): """ Represents an episode within a season """ def __init__(self, parent, path): - print 'Building an episode: ' + path - + self.parent = parent self.path = path self.name = os.path.basename(path)