slideshow 1.0
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
konachan/
|
||||
158
Catgirl.py
Normal file
158
Catgirl.py
Normal file
@@ -0,0 +1,158 @@
|
||||
import urllib.request
|
||||
|
||||
tags = "catgirl" #separate with +
|
||||
rating = "rating%3A" + "safe" #all, safe, questionable, questionableplus, explicit
|
||||
order = "order%3A" + "date" #date, fav, score, random, wide, nonwide
|
||||
site = "konachan.com" #konachan.com, yande.re, danbooru.donmai.us
|
||||
downloadnummer = 1
|
||||
|
||||
def konaBild(nummer):
|
||||
postnummer = nummer
|
||||
|
||||
|
||||
url = 'https://'+site+'/post.xml?page='+str(postnummer)+'&limit=1&tags=' + tags + '+' + order + '+' + rating
|
||||
req = urllib.request.Request(url, headers={'User-Agent': 'XYZ/3.0'})
|
||||
response = urllib.request.urlopen(req, timeout=100)
|
||||
text = str(response.read())
|
||||
|
||||
if len(text)<100:
|
||||
print("end of list")
|
||||
return 403
|
||||
|
||||
|
||||
text = formatText(text)
|
||||
#Debugtext(text)
|
||||
urllib.request.urlretrieve(getBild(text), "konachan/" + getId(text) + ".jpg")
|
||||
return ("konachan/" + getId(text) + ".jpg")
|
||||
|
||||
|
||||
def getAll():
|
||||
postnummer = 1
|
||||
url = 'https://'+site+'/post.xml?page='+str(postnummer)+'&limit=100&tags=' + tags + '+' + rating
|
||||
req = urllib.request.Request(url, headers={'User-Agent': 'XYZ/3.0'})
|
||||
response = urllib.request.urlopen(req, timeout=100)
|
||||
text = str(response.read())
|
||||
|
||||
postanzahl = int(getPostanzahl(text))
|
||||
|
||||
print("Postanzahl: "+ str(postanzahl))
|
||||
|
||||
for i in range(int(postanzahl/100)+1):
|
||||
konaMasse(i+1)
|
||||
|
||||
def getPostanzahl(input):
|
||||
output = ""
|
||||
CountStart = input.find('posts count')
|
||||
CountStart = CountStart + 13
|
||||
while 1:
|
||||
if input[CountStart]=="\"":
|
||||
break
|
||||
output = output + input[CountStart]
|
||||
CountStart = CountStart + 1
|
||||
return output
|
||||
|
||||
|
||||
def konaMasse(nummer):
|
||||
postnummer = nummer
|
||||
url = 'https://'+site+'/post.xml?page='+str(postnummer)+'&limit=100&tags=' + tags + '+' + rating #loli+rating%3Aexplicit
|
||||
req = urllib.request.Request(url, headers={'User-Agent': 'XYZ/3.0'})
|
||||
response = urllib.request.urlopen(req, timeout=100)
|
||||
text = str(response.read())
|
||||
|
||||
text = formatText(text)
|
||||
#print(text[0:20000])
|
||||
|
||||
for i in range(110):
|
||||
global downloadnummer
|
||||
|
||||
if len(text)<1000:
|
||||
print("end of list")
|
||||
return 403
|
||||
|
||||
urllib.request.urlretrieve(getBild(text), "konachan/" + getId(text) + ".jpg")
|
||||
print("Downloadnummer:" + str(downloadnummer))
|
||||
downloadnummer = downloadnummer + 1
|
||||
print(getBild(text))
|
||||
print("Id:"+getId(text))
|
||||
print("len:"+str(len(text)))
|
||||
print(text.find("sample_file_size="))
|
||||
text = text[text.find("sample_file_size=")+30:]
|
||||
|
||||
|
||||
|
||||
|
||||
def Debugtext(text):
|
||||
print (text)
|
||||
print(getBild(text))
|
||||
print(getId(text))
|
||||
print ("\n\n\n\n")
|
||||
|
||||
def formatText(input):
|
||||
schrägstrich = 0
|
||||
fuehrungzeichen = 0
|
||||
output = ""
|
||||
for x in input:
|
||||
if x=="\"":
|
||||
if fuehrungzeichen:
|
||||
output = output + x
|
||||
fuehrungzeichen = 1
|
||||
continue
|
||||
|
||||
if x=="\\":
|
||||
if schrägstrich:
|
||||
output = output + x
|
||||
schrägstrich = 1
|
||||
continue
|
||||
|
||||
if fuehrungzeichen&(x==" "):
|
||||
output = output + "\"\n"
|
||||
fuehrungzeichen = 0
|
||||
continue
|
||||
|
||||
if schrägstrich&(x=="n"):
|
||||
output = output + "\n"
|
||||
schrägstrich = 0
|
||||
continue
|
||||
|
||||
if fuehrungzeichen:
|
||||
output = output + "\""
|
||||
fuehrungzeichen = 0
|
||||
|
||||
if schrägstrich:
|
||||
output = output + "\\"
|
||||
schrägstrich = 0
|
||||
|
||||
output = output + x
|
||||
return output
|
||||
|
||||
def getBild(input):
|
||||
output = ""
|
||||
UrlStart = input.find('file_url')
|
||||
UrlStart = UrlStart + 10
|
||||
while 1:
|
||||
if input[UrlStart]=="\"":
|
||||
break
|
||||
output = output + input[UrlStart]
|
||||
UrlStart = UrlStart + 1
|
||||
return output
|
||||
|
||||
def getId(input):
|
||||
output = ""
|
||||
IdStart = input.find('\nid=')
|
||||
IdStart = IdStart + 5
|
||||
while 1:
|
||||
if input[IdStart]=="\"":
|
||||
break
|
||||
output = output + input[IdStart]
|
||||
IdStart = IdStart + 1
|
||||
return output
|
||||
|
||||
#for i in range(60):
|
||||
#print(i)
|
||||
#konaBild(i)
|
||||
#konaBild(9)
|
||||
#konaMasse(1)
|
||||
getAll()
|
||||
|
||||
|
||||
#urllib.request.urlretrieve("https://i.pinimg.com/236x/27/5b/57/275b57e1d12078cb48891894a78400e0.jpg", "local-filename.jpg")
|
||||
14
Slideshow.py
Normal file
14
Slideshow.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from flask import Flask, render_template
|
||||
import os
|
||||
|
||||
app = Flask(__name__, static_folder='konachan')
|
||||
|
||||
@app.route('/')
|
||||
def slideshow():
|
||||
image_folder = 'konachan'
|
||||
images = [f'/{image_folder}/{f}' for f in os.listdir(image_folder)
|
||||
if f.lower().endswith(('png', 'jpg', 'jpeg', 'gif'))]
|
||||
return render_template('slideshow.html', images=images)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
33
templates/slideshow.html
Normal file
33
templates/slideshow.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Slideshow</title>
|
||||
<style>
|
||||
body { background: #111; color: #fff; text-align: center; }
|
||||
img { max-width: 90vw; max-height: 90vh; margin-top: 2vh; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Slideshow</h1>
|
||||
<img id="slide" src="{{ images[0] }}" />
|
||||
<script>
|
||||
const images = {{ images | tojson }};
|
||||
const img = document.getElementById('slide');
|
||||
let i = 0;
|
||||
|
||||
function show(n) { // update helper
|
||||
i = (n + images.length) % images.length;
|
||||
img.src = images[i];
|
||||
}
|
||||
|
||||
// auto-advance every 3000 ms
|
||||
setInterval(() => show(i + 1), 3000);
|
||||
|
||||
// keyboard control
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key === 'ArrowRight') show(i + 1); // next
|
||||
if (e.key === 'ArrowLeft') show(i - 1); // previous
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user