packages feed

augur 2008.10.20.1 → 2008.11.17

raw patch · 6 files changed

+40/−17 lines, 6 filesdep ~HaXmldep ~classify

Dependency ranges changed: HaXml, classify

Files

augur.cabal view
@@ -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 @@ 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 
src/Config.hs view
@@ -17,6 +17,7 @@     | Inform { fromFiles :: [(String,FilePath)] }        -- Gather meta information.     | Add     | Remove+    | Move   { moveFormat :: String, moveDirectory :: FilePath }       deriving Show  data Flag@@ -29,5 +30,8 @@     | ParseFormat String       -- For Inform     | FromFile (String,FilePath)+      -- For Move+    | MoveFormat String+    | MoveDirectory FilePath       deriving Show 
src/Epguide.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE ScopedTypeVariables #-} -- Programmatic interface to epguides.com information. module Epguide     ( fetchTitles@@ -26,7 +27,7 @@     = 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 @@  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 @@        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" ]
src/Main.hs view
@@ -17,6 +17,7 @@  fetch  parse  rename+ move  -} @@ -29,3 +30,4 @@             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
src/Rename.hs view
@@ -13,5 +13,5 @@     = 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
src/Setup.hs view
@@ -119,6 +119,17 @@          , 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)