aktualizacja formatu originalDate
This commit is contained in:
parent
11683b816c
commit
64ce5a8da7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
/home/arab/tajemnica-atari/shadow-library.cabal:
|
||||
hash: 714bd61ef22b868b423c5ab32edbbca76e241ecb2075dced142701878c34217a
|
||||
/home/arab/tajemnica-atari/app/tajemnicaatari.hs:
|
||||
hash: d6d30253647c843a66123cc3a966da1ec5db47b670cfbccc24a2b7289493980c
|
||||
hash: 2ae5ec6f34912c37ccd5a6788081b676990ad5acc12fe86d6d08ead9776b94c7
|
||||
|
Binary file not shown.
Binary file not shown.
@ -13,6 +13,7 @@ Następnie należy wykonać następujące kroki:
|
||||
```
|
||||
cd tajemnica-atari
|
||||
stack install
|
||||
cd
|
||||
./.local/bin/tajemnicaatari
|
||||
```
|
||||
|
||||
|
@ -11,7 +11,7 @@ import Data.List.Utils (replace)
|
||||
import Text.Regex.Posix
|
||||
import Text.Printf
|
||||
|
||||
import Data.List.Utils
|
||||
import Data.List.Utils
|
||||
|
||||
|
||||
extractRecords = extractLinksWithText "//a[@class='ramka']" -- pary adres-tytuł
|
||||
@ -22,7 +22,7 @@ extractRecords = extractLinksWithText "//a[@class='ramka']" -- pary adres-tytu
|
||||
toShadowItem :: ((String, String), String) -> ShadowItem
|
||||
toShadowItem ((url, articleTitle), yearlyTitle) =
|
||||
(defaultShadowItem url title) {
|
||||
originalDate = Just newFormatDate,
|
||||
originalDate = Just newDate,
|
||||
itype = "periodical",
|
||||
format = Just "zip",
|
||||
finalUrl = url
|
||||
@ -30,13 +30,31 @@ toShadowItem ((url, articleTitle), yearlyTitle) =
|
||||
where title = "Tajemnica Atari " ++ yearlyTitle ++ " " ++ (replace "\r\n" "" (replace "\r\n " "" articleTitle))
|
||||
date = getDate url
|
||||
splitDate = split "_" date
|
||||
newFormatDate = "19" ++ splitDate !! 1 ++ "-" ++splitDate !! 0
|
||||
month = splitDate !! 0
|
||||
year = splitDate !! 1
|
||||
newDate = newFormatDate month year
|
||||
|
||||
getDate url =
|
||||
case url =~~ "/([1-9]_9[0-9]|1[0-2]_9[0-9]|[1-9]-[1-9]_9[0-9]|1[0-2]-1[0-2]_9[0-9])/" :: Maybe [[String]] of
|
||||
Just [[_, year]] -> year
|
||||
otherwise -> error $ "unexpected url: " ++ url
|
||||
|
||||
|
||||
newFormatDate :: String -> String -> String
|
||||
newFormatDate month year =
|
||||
if month =~ "^[1-9]$" then "19" ++ year ++ "-0" ++ month
|
||||
else if month =~ "^1[0-2]$" then "19" ++ year ++ "-" ++ month
|
||||
else splittedMonth month year
|
||||
|
||||
splittedMonth :: String -> String -> String
|
||||
splittedMonth month year = do
|
||||
if month =~ "^1*[0-9]-1*[0-9]$" then do
|
||||
let firstMonth = split "-" month !! 0
|
||||
let secondMonth = split "-" month !! 1
|
||||
if firstMonth =~ "^[1-9]$" && secondMonth =~ "^[1-9]$" then "19" ++ year ++ "-0" ++ firstMonth ++ "-0" ++ secondMonth
|
||||
else if firstMonth =~ "^[1-9]$" && secondMonth =~ "^1[0-9]$" then "19" ++ year ++ "-0" ++ firstMonth ++ "-" ++ secondMonth
|
||||
else if firstMonth =~ "^1[1-9]$" && secondMonth =~ "^1[0-9]$" then "19" ++ year ++ "-" ++ firstMonth ++ "-" ++ secondMonth
|
||||
else "wrong date"
|
||||
else "wrong date"
|
||||
|
||||
main = do
|
||||
let start = "http://krap.pl/mirrorz/atari/horror.mirage.com.pl/pixel/"
|
||||
@ -46,3 +64,6 @@ main = do
|
||||
lLevel=0,
|
||||
webpage=start}
|
||||
extractItemsStartingFromUrl shadowLibrary start (extractRecords >>> arr toShadowItem)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user