Skip to content

Commit

Permalink
Allow giving the filename with extension in play commands (entropia#237)
Browse files Browse the repository at this point in the history
Since commit 8e49687 ("Allow referencing audio files with filenames
outside [a-zA-Z0-9_] (entropia#236)"), all filenames could be given to the play
command, however the user had to cut off the file extension manually.
First search for the full filename, before trying with the standard
extension.

To allow basic filenames without quoting, "." is now also allowed in
identifiers for the play command.

Idea and code suggestion by Joachim Breitner.

Co-authored-by: Thomas Bleher <[email protected]>
  • Loading branch information
tbleher and Thomas Bleher authored Dec 2, 2020
1 parent 0441235 commit 9313000
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## 1.10 (UNRELEASED)

* Audio filenames can now be quoted, to support filenames with characters
outside the range `a-zA-Z0-9_`
outside the range `a-zA-Z0-9_`. Audio files can also be given including
their extension.
* Support for the `stop` and `restart` codes (generated by default)
* The `set-language` command truncates long language names (like `ITALIAN`)
automatically.
Expand Down
10 changes: 4 additions & 6 deletions src/TipToiYaml.hs
Original file line number Diff line number Diff line change
Expand Up @@ -843,11 +843,9 @@ ttYaml2tt no_date dir (TipToiYAML {..}) extCodes = do
Just (lang, txt) -> do
Right <$> readFile' (ttsFileName lang txt)
Nothing -> do
let paths = [ combine dir relpath
| ext <- map snd fileMagics
, let pat = fromMaybe "%s" ttyMedia_Path
, let relpath = printf pat fn <.> ext
]
let pat = fromMaybe "%s" ttyMedia_Path
let basePath = printf pat fn
let paths = map (combine dir) (basePath : [basePath <.> ext | (_,ext) <- fileMagics ])
ex <- filterM doesFileExist paths
case ex of
[] -> do
Expand Down Expand Up @@ -955,7 +953,7 @@ parsePlayList :: Parser [String]
parsePlayList = P.commaSep lexer $ parseAudioRef

parseAudioRef :: Parser String
parseAudioRef = (P.lexeme lexer $ many1 (alphaNum <|> char '_')) <|> P.stringLiteral lexer
parseAudioRef = (P.lexeme lexer $ many1 (alphaNum <|> char '_' <|> char '.')) <|> P.stringLiteral lexer

parseScriptRef :: Parser String
parseScriptRef = P.lexeme lexer $ many1 (alphaNum <|> char '_')
Expand Down

0 comments on commit 9313000

Please sign in to comment.