Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aichecker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Eggers
aichecker
Commits
a92a3f40
Commit
a92a3f40
authored
3 months ago
by
Jan Eggers
Browse files
Options
Downloads
Patches
Plain Diff
Checkpoint
parent
14ad06ec
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyproject.toml
+3
-0
3 additions, 0 deletions
pyproject.toml
tg_hr_check.py
+37
-10
37 additions, 10 deletions
tg_hr_check.py
with
40 additions
and
10 deletions
pyproject.toml
+
3
−
0
View file @
a92a3f40
...
@@ -17,6 +17,9 @@ dependencies = [
...
@@ -17,6 +17,9 @@ dependencies = [
"requests"
,
# Alle bsky-Calls über Requests
"requests"
,
# Alle bsky-Calls über Requests
"openai"
,
# für die Bildbeschreibung
"openai"
,
# für die Bildbeschreibung
"ollama"
,
# für die Bildbeschreibung
"ollama"
,
# für die Bildbeschreibung
"openai-whisper"
,
# für die Transkription
"bs4"
,
# Seitenanalyse
"pydub"
,
# Transkription/Audioformate
]
]
readme
=
"README.md"
readme
=
"README.md"
license
=
{
file
=
"LICENSE"
}
license
=
{
file
=
"LICENSE"
}
...
...
This diff is collapsed.
Click to expand it.
tg_hr_check.py
+
37
−
10
View file @
a92a3f40
...
@@ -39,12 +39,11 @@ def is_hr_url(url):
...
@@ -39,12 +39,11 @@ def is_hr_url(url):
return
True
return
True
return
False
return
False
def
find_
hr_
links
(
text
):
def
find_links
(
text
):
# Regex, um Links zu extrahieren
# Regex, um Links
aus Text
zu extrahieren
if
text
is
None
or
text
==
""
:
if
text
is
None
or
text
==
""
:
return
[]
return
[]
urls
=
re
.
findall
(
r
'
https?://[^\s]+
'
,
text
)
urls
=
re
.
findall
(
r
'
https?://[^\s]+
'
,
text
)
hr_links
=
[
url
for
url
in
urls
if
is_hr_url
(
url
)]
return
hr_links
return
hr_links
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
@@ -52,14 +51,30 @@ if __name__ == "__main__":
...
@@ -52,14 +51,30 @@ if __name__ == "__main__":
# Schau, ob es schon Daten gibt
# Schau, ob es schon Daten gibt
if
not
os
.
path
.
exists
(
'
tg-checks
'
):
if
not
os
.
path
.
exists
(
'
tg-checks
'
):
os
.
makedirs
(
'
tg-checks
'
)
os
.
makedirs
(
'
tg-checks
'
)
filename
=
f
'
tg-checks/c
onfig
.csv
'
filename
=
f
'
tg-checks/c
hannels
.csv
'
if
os
.
path
.
exists
(
filename
):
if
os
.
path
.
exists
(
filename
):
channels_df
=
pd
.
read_csv
(
filename
)
channels_df
=
pd
.
read_csv
(
filename
)
print
(
f
"
Config-Datei mit
{
len
(
channels_df
)
}
Kanälen
"
)
print
(
f
"
Config-Datei mit
{
len
(
channels_df
)
}
Kanälen
"
)
channels
=
channels_df
[
'
Kanal
'
].
to_list
()
channels
=
channels_df
[
'
Kanal
'
].
to_list
()
else
:
else
:
channels
=
[
'
fragunsdochdasoriginal
'
,
'
freiheitffm
'
]
channels
=
[
'
fragunsdochdasoriginal
'
,
'
freiheitffm
'
]
hr_links
=
[]
# Datei mit den Links, auf die geprüft werden soll
# Durchsucht in den gefunden Links auf diese Strings (naiv).
#
# Strings sollten also z.B. hessenschau.de
filename
=
f
'
tg-checks/checks.csv
'
if
os
.
path
.
exists
(
filename
):
checks_df
=
pd
.
read_csv
(
filename
)
checks
=
checks_df
[
'
Kanal
'
].
to_list
()
else
:
channels
=
[
'
hessenschau.de
'
,
'
hrinforadio.de
'
,
"
hr3.de
"
,
'
hrfernsehen.de
'
,
'
ardmediathek.hr
'
,
'
hr.de
'
,
]
warning_links
=
[]
for
c
in
channels
:
for
c
in
channels
:
existing_df
=
pd
.
DataFrame
()
existing_df
=
pd
.
DataFrame
()
profile
=
tgc_profile
(
c
)
profile
=
tgc_profile
(
c
)
...
@@ -93,14 +108,26 @@ if __name__ == "__main__":
...
@@ -93,14 +108,26 @@ if __name__ == "__main__":
print
(
f
"
Einlesen
{
start_post
+
1
}
bis
{
last_post
}
...
"
)
print
(
f
"
Einlesen
{
start_post
+
1
}
bis
{
last_post
}
...
"
)
posts
=
tgc_read_range
(
c
,
start_post
+
1
,
last_post
,
save
=
False
,
describe
=
False
)
posts
=
tgc_read_range
(
c
,
start_post
+
1
,
last_post
,
save
=
False
,
describe
=
False
)
# Nach hr-Links suchen
# Nach hr-Links suchen
# Die Posts, die hr-Links enthalten, markieren
# und später als Tabelle ausgeben, die dann von einem Watch-Programm
# beobachtet wird
alerts
=
[]
for
post
in
posts
:
for
post
in
posts
:
interessant
=
find_hr_links
(
post
[
'
text
'
])
# Links gegen Liste prüfen
if
post
[
'
links
'
]:
for
l
in
post
[
'
links
'
]:
interessant
.
extend
(
post
[
'
links
'
])
for
ch
in
checks
:
hr_links
.
extend
(
interessant
)
# Taucht der Link in der Liste auf?
print
(
f
"
Potenziell interessant:
{
interessant
}
"
)
alert
=
post
# Speichern, was verlinkt wurde
alert
[
'
alert
'
]
=
ch
alerts
.
append
(
alert
)
print
(
f
"
Neue Alerts:
"
)
for
a
in
alerts
:
print
(
a
)
# Posts anhängen an das csv dieses Kanals
# Posts anhängen an das csv dieses Kanals
alerts_df
=
pd
.
DataFrame
(
alerts
)
df
=
pd
.
DataFrame
(
posts
)
df
=
pd
.
DataFrame
(
posts
)
df
=
pd
.
concat
([
existing_df
,
df
]).
drop_duplicates
(
subset
=
[
'
nr
'
]).
reset_index
(
drop
=
True
)
df
=
pd
.
concat
([
existing_df
,
df
]).
drop_duplicates
(
subset
=
[
'
nr
'
]).
reset_index
(
drop
=
True
)
df
.
to_csv
(
f
'
tg-checks/
{
c
}
.csv
'
,
index
=
False
)
# Save to CSV for example
df
.
to_csv
(
f
'
tg-checks/
{
c
}
.csv
'
,
index
=
False
)
# Save to CSV for example
print
(
"
Ende Gelände.
"
)
print
(
"
Ende Gelände.
"
)
df
.
to_csv
(
f
'
tg-checks/alerts.csv
'
,
index
=
False
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment