Compare commits
No commits in common. "782b629929888315eed31bf1cfc4c25fe1a4dfef" and "32e81c2d93f725b6b810f1ee19c35b47e9bbe687" have entirely different histories.
782b629929
...
32e81c2d93
3 changed files with 1 additions and 28 deletions
25
main.py
25
main.py
|
|
@ -386,28 +386,6 @@ def has_content_image(images: list[dict]) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def get_wikipedia_extract(title: str) -> str:
|
||||
"""Get the first paragraph extract of a Wikipedia article."""
|
||||
params = {
|
||||
"action": "query",
|
||||
"prop": "extracts",
|
||||
"exintro": "true",
|
||||
"explaintext": "true",
|
||||
"titles": title,
|
||||
"format": "json",
|
||||
}
|
||||
headers = {"User-Agent": WIKIMEDIA_USER_AGENT}
|
||||
try:
|
||||
r = requests.get(WIKIPEDIA_API, params=params, headers=headers)
|
||||
data = r.json()
|
||||
pages = data.get("query", {}).get("pages", {})
|
||||
for page in pages.values():
|
||||
return page.get("extract", "")
|
||||
except Exception:
|
||||
pass
|
||||
return ""
|
||||
|
||||
|
||||
def get_articles_without_images(
|
||||
category: str,
|
||||
limit: int = 200,
|
||||
|
|
@ -752,8 +730,6 @@ def start() -> str:
|
|||
flickr_search = f'"{without_middle}"'
|
||||
search_result = search_flickr(flickr_search, page)
|
||||
|
||||
wikipedia_extract = get_wikipedia_extract(wiki_part2)
|
||||
|
||||
return flask.render_template(
|
||||
"combined.html",
|
||||
name=name,
|
||||
|
|
@ -761,7 +737,6 @@ def start() -> str:
|
|||
search_result=search_result,
|
||||
cat=cat,
|
||||
flickr_search=flickr_search,
|
||||
wikipedia_extract=wikipedia_extract,
|
||||
)
|
||||
|
||||
if "/in/" in flickr_url:
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@
|
|||
<p><a href="{{ url_for('category_search', cat=cat) }}">← Back to category</a></p>
|
||||
{% endif %}
|
||||
<p>Wikipedia article: {{ name }}</p>
|
||||
{% if wikipedia_extract %}<p class="text-muted">{{ wikipedia_extract }}</p>{% endif %}
|
||||
<form action="{{ url_for(request.endpoint) }}" class="mb-3 d-flex align-items-center gap-2">
|
||||
<input type="hidden" name="enwp" value="{{ enwp }}">
|
||||
{% if cat %}<input type="hidden" name="cat" value="{{ cat }}">{% endif %}
|
||||
|
|
@ -152,7 +151,6 @@
|
|||
<p><a href="{{ url_for('category_search', cat=cat) }}">← Back to category</a></p>
|
||||
{% endif %}
|
||||
<p>Wikipedia article: {{ name }}</p>
|
||||
{% if wikipedia_extract %}<p class="text-muted">{{ wikipedia_extract }}</p>{% endif %}
|
||||
<form action="{{ url_for(request.endpoint) }}" class="mb-3 d-flex align-items-center gap-2">
|
||||
<input type="hidden" name="enwp" value="{{ enwp }}">
|
||||
{% if cat %}<input type="hidden" name="cat" value="{{ cat }}">{% endif %}
|
||||
|
|
|
|||
2
update_flickr_uploads.py
Executable file → Normal file
2
update_flickr_uploads.py
Executable file → Normal file
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Find UploadWizard contributions that are from Flickr and add them to the database.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue