summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--augur.cabal15
-rw-r--r--src/Config.hs4
-rw-r--r--src/Epguide.hs23
-rw-r--r--src/Main.hs2
-rw-r--r--src/Rename.hs2
-rw-r--r--src/Setup.hs11
6 files changed, 40 insertions, 17 deletions
diff --git a/augur.cabal b/augur.cabal
index c3b838a..53cda33 100644
--- a/augur.cabal
+++ b/augur.cabal
@@ -1,8 +1,8 @@
Name: augur
-Version: 2008.10.20.1
+Version: 2008.11.17
Copyright: 2008, Lemmih
-Build-Depends: base, filepath, directory, bytestring, HaXml,
- containers, mtl, process, classify
+Build-Depends: base, filepath, directory, bytestring, HaXml >= 1.13 && < 1.14,
+ containers, mtl, process, classify >= 2008.11.17
Build-Type: Simple
License: BSD3
License-File: LICENSE
@@ -10,9 +10,12 @@ Author: Lemmih <lemmih@gmail.com>
Maintainer: Lemmih <lemmih@gmail.com>
Synopsis: Renaming media collections in a breeze.
Description: Augur is a tool for parsing and renaming TV episodes. It can recognise a wide
- variety of formats, like: @The.4400.S04E02.DSR.XviD-ORENJi.avi@ which translates
- to @The 4400 - 4x02 - Fear Itself.avi@. Or: @24.S06E01.6AM.TO.7AM.PROPER.DVDRip.XviD-MEMETiC.avi@
- to @24 - 6x01 - Day 6: 6:00 AM - 7:00 AM.avi@. Dates are also supported as the episode number.
+ variety of formats, like:
+ .
+ > The.4400.S04E02.DSR.XviD-ORENJi.avi -> The 4400 - 4x02 - Fear Itself.avi
+ > 24.S06E01.6AM.TO.7AM.PROPER.DVDRip.XviD-MEMETiC.avi -> 24 - 6x01 - Day 6: 6:00 AM - 7:00 AM.avi
+ .
+ Dates are also supported as the episode number.
The pretty printing format is configurable with the default being @%S - %sx%2e - %E.%l@.
Category: Text
diff --git a/src/Config.hs b/src/Config.hs
index 79cceaf..4df05d2 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -17,6 +17,7 @@ data Action
| Inform { fromFiles :: [(String,FilePath)] } -- Gather meta information.
| Add
| Remove
+ | Move { moveFormat :: String, moveDirectory :: FilePath }
deriving Show
data Flag
@@ -29,5 +30,8 @@ data Flag
| ParseFormat String
-- For Inform
| FromFile (String,FilePath)
+ -- For Move
+ | MoveFormat String
+ | MoveDirectory FilePath
deriving Show
diff --git a/src/Epguide.hs b/src/Epguide.hs
index 3c6f8e8..f1cf846 100644
--- a/src/Epguide.hs
+++ b/src/Epguide.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE ScopedTypeVariables #-}
-- Programmatic interface to epguides.com information.
module Epguide
( fetchTitles
@@ -26,7 +27,7 @@ fetchTitles cfg series
= do let url = mkGoogleUrl "epguides.com" series
mbDoc <- try $ downloadAsXML cfg url
case mbDoc of
- Left _err -> return []
+ Left (err::SomeException) -> return []
Right doc -> fetchTitles' doc
fetchTitlesFromFile :: Config -> FilePath
@@ -38,8 +39,9 @@ fetchTitlesFromFile cfg inp
fetchTitles' :: Document -- ^ Input
-> IO [(LocalEpisodeIndex,String)]
-fetchTitles' (Document _ _ (Elem _ _ cs) _)
- = do let cs' = concatMap (xtract "//pre") cs
+fetchTitles' (Document _ _ elt _)
+ = do let Elem _ _ cs = xmlUnEscape stdXmlEscaper elt
+ cs' = concatMap (xtract "//pre") $ cs
titles = [ (index,title) | CElem (Elem "pre" _ cs'') <- cs'
, [CString _ l, CElem (Elem "a" attrs titleParts)] <- split 2 cs''
-- FIXME: support escape codes like &aacute
@@ -62,13 +64,14 @@ parseEpNum inp = fromMaybe [] $ flip fromReadP inp $
satisfy (not.isDigit)
guard (s > 0 && e > 0)
many anyChar
- satisfy (not.isDigit)
- day <- fmap read $ many1 digit
- skipSpaces
- month <- getMonth
- skipSpaces
- year <- fmap read $ many1 digit
- return [EpIdx s e, DateIdx (year+2000) month day]
+ date <- option [] $ do satisfy (not.isDigit)
+ day <- fmap read $ many1 digit
+ skipSpaces
+ month <- getMonth
+ skipSpaces
+ year <- fmap read $ many1 digit
+ return [DateIdx (year+2000) month day]
+ return $ [EpIdx s e] ++ date
getMonth = choice $ map (\(n,str) -> string str >> return n) $ zip [1..]
[ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]
diff --git a/src/Main.hs b/src/Main.hs
index 77fb3d8..6e8033c 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -17,6 +17,7 @@ import Config
fetch
parse
rename
+ move
-}
@@ -29,3 +30,4 @@ main = do (action, args, conf) <- parseArguments =<< getArgs
Parse format -> do ppArgs <- parse conf format args
forM_ ppArgs putStrLn
Rename format -> rename conf format args
+-- Move format dir -> move conf format dir args \ No newline at end of file
diff --git a/src/Rename.hs b/src/Rename.hs
index 085f8c8..e71190c 100644
--- a/src/Rename.hs
+++ b/src/Rename.hs
@@ -13,5 +13,5 @@ rename cfg format paths
= do ppNames <- parse cfg format (map takeFileName paths)
forM_ (zip paths ppNames) $ \(path, parsed) ->
do let dest = dropFileName path </> parsed
- when (confVerbose cfg >= 2) $ putStrLn $ path ++ " -> " ++ dest
+ when (confVerbose cfg >= 1) $ putStrLn $ path ++ " -> " ++ dest
unless (confDryRun cfg) $ renameFile path dest
diff --git a/src/Setup.hs b/src/Setup.hs
index 4f588f1..f75f1c6 100644
--- a/src/Setup.hs
+++ b/src/Setup.hs
@@ -119,6 +119,17 @@ removeCmd = Cmd
, cmdAction = Remove
, cmdMerge = \_ -> id }
+moveCmd = Cmd
+ { cmdName = "move"
+ , cmdHelp = ""
+ , cmdDescription = ""
+ , cmdOptions = [Option "f" ["format"] (ReqArg MoveFormat "format") ("Destination format. Default: %S/")
+ ,Option "d" ["directory"] (ReqArg MoveDirectory "directory") ("Destination base. Default: ./")]
+ , cmdAction = Move "%S/" "./"
+ , cmdMerge = \f a -> case f of
+ MoveFormat fm -> a{moveFormat = fm}
+ MoveDirectory dir -> a{moveDirectory = dir}}
+
lookupCommand :: String -> [Cmd] -> Maybe Cmd
lookupCommand name = find ((==name) . cmdName)