mirror of
https://codeberg.org/scip/kleingebaeck.git
synced 2025-12-17 20:41:01 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4030d04b06 | ||
| eff0af0b34 | |||
| 34b1ad9d1e | |||
|
|
6675c4d232 |
5
ad.go
5
ad.go
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright © 2023-2024 Thomas von Dein
|
Copyright © 2023-2025 Thomas von Dein
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -45,6 +45,9 @@ type Ad struct {
|
|||||||
Text string `goquery:"p#viewad-description-text,html"`
|
Text string `goquery:"p#viewad-description-text,html"`
|
||||||
Images []string `goquery:".galleryimage-element img,[src]"`
|
Images []string `goquery:".galleryimage-element img,[src]"`
|
||||||
Expire string
|
Expire string
|
||||||
|
|
||||||
|
// runtime computed
|
||||||
|
Year, Day, Month string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used by slog to pretty print an ad
|
// Used by slog to pretty print an ad
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright © 2023-2024 Thomas von Dein
|
Copyright © 2023-2025 Thomas von Dein
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -34,7 +34,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION string = "0.3.16"
|
VERSION string = "0.3.18"
|
||||||
Baseuri string = "https://www.kleinanzeigen.de"
|
Baseuri string = "https://www.kleinanzeigen.de"
|
||||||
Listuri string = "/s-bestandsliste.html"
|
Listuri string = "/s-bestandsliste.html"
|
||||||
Defaultdir string = "."
|
Defaultdir string = "."
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ user = 00000000
|
|||||||
loglevel = "verbose"
|
loglevel = "verbose"
|
||||||
|
|
||||||
# directory where to store downloaded ads. kleingebaeck will try to
|
# directory where to store downloaded ads. kleingebaeck will try to
|
||||||
# create it. must be a quoted string.
|
# create it. must be a quoted string. You can also include a couple of
|
||||||
|
# template variables, e.g:
|
||||||
|
# outdir = "test-{{.Year}}-{{.Month}}-{{.Day}}"
|
||||||
outdir = "test"
|
outdir = "test"
|
||||||
|
|
||||||
# template for stored adlistings.
|
# template for stored adlistings.
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
.\" ========================================================================
|
.\" ========================================================================
|
||||||
.\"
|
.\"
|
||||||
.IX Title "KLEINGEBAECK 1"
|
.IX Title "KLEINGEBAECK 1"
|
||||||
.TH KLEINGEBAECK 1 "2025-02-10" "1" "User Commands"
|
.TH KLEINGEBAECK 1 "2025-02-27" "1" "User Commands"
|
||||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||||
.\" way too many mistakes in technical documents.
|
.\" way too many mistakes in technical documents.
|
||||||
.if n .ad l
|
.if n .ad l
|
||||||
@@ -260,6 +260,29 @@ The ad directory name can be modified using the following ad values:
|
|||||||
.PP
|
.PP
|
||||||
It can only be configured in the config file. By default only
|
It can only be configured in the config file. By default only
|
||||||
\&\f(CW\*(C`{{.Slug}}\*(C'\fR is being used, this is the title of the ad in url format.
|
\&\f(CW\*(C`{{.Slug}}\*(C'\fR is being used, this is the title of the ad in url format.
|
||||||
|
.SS "\s-1AD NAME TEMPLATE\s0"
|
||||||
|
.IX Subsection "AD NAME TEMPLATE"
|
||||||
|
The name of the directory per ad can be tuned as well:
|
||||||
|
.ie n .IP """{{.Year}}""" 4
|
||||||
|
.el .IP "\f(CW{{.Year}}\fR" 4
|
||||||
|
.IX Item "{{.Year}}"
|
||||||
|
.PD 0
|
||||||
|
.ie n .IP """{{.Month}}""" 4
|
||||||
|
.el .IP "\f(CW{{.Month}}\fR" 4
|
||||||
|
.IX Item "{{.Month}}"
|
||||||
|
.ie n .IP """{{.Day}}""" 4
|
||||||
|
.el .IP "\f(CW{{.Day}}\fR" 4
|
||||||
|
.IX Item "{{.Day}}"
|
||||||
|
.ie n .IP """{{.Slug}}""" 4
|
||||||
|
.el .IP "\f(CW{{.Slug}}\fR" 4
|
||||||
|
.IX Item "{{.Slug}}"
|
||||||
|
.ie n .IP """{{.Category}}""" 4
|
||||||
|
.el .IP "\f(CW{{.Category}}\fR" 4
|
||||||
|
.IX Item "{{.Category}}"
|
||||||
|
.ie n .IP """{{.ID}}""" 4
|
||||||
|
.el .IP "\f(CW{{.ID}}\fR" 4
|
||||||
|
.IX Item "{{.ID}}"
|
||||||
|
.PD
|
||||||
.SS "\s-1AD TEMPLATE\s0"
|
.SS "\s-1AD TEMPLATE\s0"
|
||||||
.IX Subsection "AD TEMPLATE"
|
.IX Subsection "AD TEMPLATE"
|
||||||
The ad listing itself can be modified as well, using the same
|
The ad listing itself can be modified as well, using the same
|
||||||
@@ -344,7 +367,7 @@ Also there's currently no parallelization implemented. This will
|
|||||||
change in the future.
|
change in the future.
|
||||||
.SH "LICENSE"
|
.SH "LICENSE"
|
||||||
.IX Header "LICENSE"
|
.IX Header "LICENSE"
|
||||||
Copyright 2023\-2024 Thomas von Dein
|
Copyright 2023\-2025 Thomas von Dein
|
||||||
.PP
|
.PP
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the \s-1GNU\s0 General Public License as published by
|
it under the terms of the \s-1GNU\s0 General Public License as published by
|
||||||
|
|||||||
@@ -100,6 +100,16 @@ TEMPLATES
|
|||||||
It can only be configured in the config file. By default only
|
It can only be configured in the config file. By default only
|
||||||
"{{.Slug}}" is being used, this is the title of the ad in url format.
|
"{{.Slug}}" is being used, this is the title of the ad in url format.
|
||||||
|
|
||||||
|
AD NAME TEMPLATE
|
||||||
|
The name of the directory per ad can be tuned as well:
|
||||||
|
|
||||||
|
"{{.Year}}"
|
||||||
|
"{{.Month}}"
|
||||||
|
"{{.Day}}"
|
||||||
|
"{{.Slug}}"
|
||||||
|
"{{.Category}}"
|
||||||
|
"{{.ID}}"
|
||||||
|
|
||||||
AD TEMPLATE
|
AD TEMPLATE
|
||||||
The ad listing itself can be modified as well, using the same variables
|
The ad listing itself can be modified as well, using the same variables
|
||||||
as the ad name template above.
|
as the ad name template above.
|
||||||
@@ -174,7 +184,7 @@ LIMITATIONS
|
|||||||
in the future.
|
in the future.
|
||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
Copyright 2023-2024 Thomas von Dein
|
Copyright 2023-2025 Thomas von Dein
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it
|
This program is free software: you can redistribute it and/or modify it
|
||||||
under the terms of the GNU General Public License as published by the
|
under the terms of the GNU General Public License as published by the
|
||||||
|
|||||||
@@ -119,6 +119,27 @@ The ad directory name can be modified using the following ad values:
|
|||||||
It can only be configured in the config file. By default only
|
It can only be configured in the config file. By default only
|
||||||
C<{{.Slug}}> is being used, this is the title of the ad in url format.
|
C<{{.Slug}}> is being used, this is the title of the ad in url format.
|
||||||
|
|
||||||
|
=head2 AD NAME TEMPLATE
|
||||||
|
|
||||||
|
The name of the directory per ad can be tuned as well:
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item C<{{.Year}}>
|
||||||
|
|
||||||
|
=item C<{{.Month}}>
|
||||||
|
|
||||||
|
=item C<{{.Day}}>
|
||||||
|
|
||||||
|
=item C<{{.Slug}}>
|
||||||
|
|
||||||
|
=item C<{{.Category}}>
|
||||||
|
|
||||||
|
=item C<{{.ID}}>
|
||||||
|
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=head2 AD TEMPLATE
|
=head2 AD TEMPLATE
|
||||||
|
|
||||||
The ad listing itself can be modified as well, using the same
|
The ad listing itself can be modified as well, using the same
|
||||||
@@ -202,7 +223,7 @@ change in the future.
|
|||||||
|
|
||||||
=head1 LICENSE
|
=head1 LICENSE
|
||||||
|
|
||||||
Copyright 2023-2024 Thomas von Dein
|
Copyright 2023-2025 Thomas von Dein
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
8
mkrel.sh
8
mkrel.sh
@@ -45,15 +45,21 @@ for D in $DIST; do
|
|||||||
os=${D/\/*/}
|
os=${D/\/*/}
|
||||||
arch=${D/*\//}
|
arch=${D/*\//}
|
||||||
binfile="releases/${tool}-${os}-${arch}-${version}"
|
binfile="releases/${tool}-${os}-${arch}-${version}"
|
||||||
|
pie=""
|
||||||
|
|
||||||
if test "$os" = "windows"; then
|
if test "$os" = "windows"; then
|
||||||
binfile="${binfile}.exe"
|
binfile="${binfile}.exe"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$D" = "linux/amd64"; then
|
||||||
|
pie="-buildmode=pie"
|
||||||
|
fi
|
||||||
|
|
||||||
tardir="${tool}-${os}-${arch}-${version}"
|
tardir="${tool}-${os}-${arch}-${version}"
|
||||||
tarfile="releases/${tool}-${os}-${arch}-${version}.tar.gz"
|
tarfile="releases/${tool}-${os}-${arch}-${version}.tar.gz"
|
||||||
set -x
|
set -x
|
||||||
GOOS=${os} GOARCH=${arch} go build -tags osusergo,netgo -ldflags "-extldflags=-static" -o ${binfile}
|
GOOS=${os} GOARCH=${arch} go build -tags osusergo,netgo -ldflags "-extldflags=-static -w" --trimpath $pie -o ${binfile}
|
||||||
|
strip --strip-all ${binfile}
|
||||||
mkdir -p ${tardir}
|
mkdir -p ${tardir}
|
||||||
cp ${binfile} README.md LICENSE ${tardir}/
|
cp ${binfile} README.md LICENSE ${tardir}/
|
||||||
echo 'tool = kleingebaeck
|
echo 'tool = kleingebaeck
|
||||||
|
|||||||
10
scrape.go
10
scrape.go
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright © 2023-2024 Thomas von Dein
|
Copyright © 2023-2025 Thomas von Dein
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -88,7 +88,13 @@ func ScrapeUser(fetch *Fetcher) error {
|
|||||||
|
|
||||||
// scrape an ad. uri is the full uri of the ad, dir is the basedir
|
// scrape an ad. uri is the full uri of the ad, dir is the basedir
|
||||||
func ScrapeAd(fetch *Fetcher, uri string) error {
|
func ScrapeAd(fetch *Fetcher, uri string) error {
|
||||||
advertisement := &Ad{}
|
now := time.Now()
|
||||||
|
|
||||||
|
advertisement := &Ad{
|
||||||
|
Year: now.Format("2006"),
|
||||||
|
Month: now.Format("01"),
|
||||||
|
Day: now.Format("02"),
|
||||||
|
}
|
||||||
|
|
||||||
// extract slug and id from uri
|
// extract slug and id from uri
|
||||||
uriparts := strings.Split(uri, "/")
|
uriparts := strings.Split(uri, "/")
|
||||||
|
|||||||
6
store.go
6
store.go
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright © 2023-2024 Thomas von Dein
|
Copyright © 2023-2025 Thomas von Dein
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -44,8 +44,8 @@ func OutDirName(conf *Config) (string, error) {
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
data := OutdirData{
|
data := OutdirData{
|
||||||
Year: now.Format("2006"),
|
Year: now.Format("2006"),
|
||||||
Month: now.Format("02"),
|
Month: now.Format("01"),
|
||||||
Day: now.Format("01"),
|
Day: now.Format("02"),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tmpl.Execute(&buf, data)
|
err = tmpl.Execute(&buf, data)
|
||||||
|
|||||||
Reference in New Issue
Block a user