import re
import os
import time
import requests
from random import *
from tkinter import *
import tkinter.filedialog as fd
class Download():
def __init__ (self, link):
self.mainlink = link + '?p='
self.allinks = []
self.n = 0
def randname(n):
return ''.join(sample(''.join([chr(i)*randint(1,3) for i in range(97,123)])+ str(randint(11111,99999))*10, n))
def rawlinks(self):
allinks = []
p = 0
mainpage = requests.get(self.mainlink+str(p)).content.decode()
number_of_pages = int(re.search(r'(?<=Images:<\/td><td\s{1}class=\"gdt2\">)(\d+)(?=\s{1}@)',mainpage).group())//40
raw_links = re.findall(r'(?<=href=\")(http:\/\/g\.e-hentai.org\/s\/[a-z0-9\/-]+\d+\b)(?=\")',mainpage)
while p <= number_of_pages+1:
raw_links = re.findall(r'(?<=href=\")(http:\/\/g\.e-hentai.org\/s\/[a-z0-9\/-]+\d+\b)(?=\")',mainpage)
for elem in raw_links:
allinks+=elem.split(' ')
raw_links = []
mainpage = requests.get(self.mainlink+str(p)).content.decode()
p+=1
self.allinks = list(set(allinks))
self.n = len(self.allinks)
def load(self):
j = 0
try:
while j <= self.n:
page = requests.get(self.allinks[j]).content.decode()
true_link = re.search(r'(?<=src=\")(http:\/\/\d{1,3}\.\d{1,3}\S+)(?=\"\s{1}st)', page).group()
ext = re.search(r'(?<=\w{1}\.{1})([jpgnife]{3,4})(?=\b)',true_link).group()
pic = requests.get(true_link).content
time.sleep(1)
f = open(Download.randname(16)+'.'+ ext,'wb')
f.write(pic)
f.close()
j+=1
except IndexError:
pass
def copypast(e):
lk=mainw.selection_get(selection='CLIPBOARD')
mylink.insert(1, lk)
def opendir():
f = fd.askdirectory()
try:
os.chdir(f)
except: pass
def go():
s = mylink.get()
b2.configure(state='disabled')
mylink.configure(state='disabled')
d = Download(s)
d.rawlinks()
d.load()
b2.configure(state='normal')
mylink.configure(state='normal')
mylink.delete(0,END)
mainw = Tk()
mainw.title('g.e-hentai.org downloader')
mainw.resizable(0,0)
mainw.geometry('300x240')
mylink = Entry(mainw,width=30)
text1 = Label(mainw, text='My link:',font=14)
text2 = Label(mainw,text='My folder:',font=14)
b = Button(text='...',height=1,width=22,command=opendir)
b2 = Button(height=6,width=18,bg='#80DAEB',text='Start',fg='purple',font=18,command=go)
b2.place(x=80,y=100)
b.place(x=90,y=45)
text1.place(x=8,y=10)
text2.place(x=8,y=48)
mylink.place(x=75,y=10)
mylink.bind(lambda event='<Control-v>' : copypast)
mainw.mainloop()
aW1wb3J0IHJlCmltcG9ydCBvcwppbXBvcnQgdGltZQppbXBvcnQgcmVxdWVzdHMKZnJvbSByYW5kb20gaW1wb3J0ICoKZnJvbSB0a2ludGVyIGltcG9ydCAqCmltcG9ydCB0a2ludGVyLmZpbGVkaWFsb2cgYXMgZmQKY2xhc3MgRG93bmxvYWQoKToKICAgIGRlZiBfX2luaXRfXyAoc2VsZiwgbGluayk6CiAgICAgICAgc2VsZi5tYWlubGluayA9IGxpbmsgKyAnP3A9JwogICAgICAgIHNlbGYuYWxsaW5rcyA9IFtdCiAgICAgICAgc2VsZi5uID0gMAoKICAgIGRlZiByYW5kbmFtZShuKToKICAgICAgICByZXR1cm4gJycuam9pbihzYW1wbGUoJycuam9pbihbY2hyKGkpKnJhbmRpbnQoMSwzKSBmb3IgaSBpbiByYW5nZSg5NywxMjMpXSkrIHN0cihyYW5kaW50KDExMTExLDk5OTk5KSkqMTAsIG4pKQoKICAgIGRlZiByYXdsaW5rcyhzZWxmKToKICAgICAgICBhbGxpbmtzID0gW10KICAgICAgICBwID0gMAogICAgICAgIG1haW5wYWdlID0gcmVxdWVzdHMuZ2V0KHNlbGYubWFpbmxpbmsrc3RyKHApKS5jb250ZW50LmRlY29kZSgpCiAgICAgICAgbnVtYmVyX29mX3BhZ2VzID0gaW50KHJlLnNlYXJjaChyJyg/PD1JbWFnZXM6PFwvdGQ+PHRkXHN7MX1jbGFzcz1cImdkdDJcIj4pKFxkKykoPz1cc3sxfUApJyxtYWlucGFnZSkuZ3JvdXAoKSkvLzQwCiAgICAgICAgcmF3X2xpbmtzID0gcmUuZmluZGFsbChyJyg/PD1ocmVmPVwiKShodHRwOlwvXC9nXC5lLWhlbnRhaS5vcmdcL3NcL1thLXowLTlcLy1dK1xkK1xiKSg/PVwiKScsbWFpbnBhZ2UpCiAgICAgICAgd2hpbGUgcCA8PSBudW1iZXJfb2ZfcGFnZXMrMToKICAgICAgICAgICAgcmF3X2xpbmtzID0gcmUuZmluZGFsbChyJyg/PD1ocmVmPVwiKShodHRwOlwvXC9nXC5lLWhlbnRhaS5vcmdcL3NcL1thLXowLTlcLy1dK1xkK1xiKSg/PVwiKScsbWFpbnBhZ2UpCiAgICAgICAgICAgIGZvciBlbGVtIGluIHJhd19saW5rczoKICAgICAgICAgICAgICAgIGFsbGlua3MrPWVsZW0uc3BsaXQoJyAnKQogICAgICAgICAgICByYXdfbGlua3MgPSBbXQogICAgICAgICAgICBtYWlucGFnZSA9IHJlcXVlc3RzLmdldChzZWxmLm1haW5saW5rK3N0cihwKSkuY29udGVudC5kZWNvZGUoKQogICAgICAgICAgICBwKz0xCiAgICAgICAgc2VsZi5hbGxpbmtzID0gbGlzdChzZXQoYWxsaW5rcykpCiAgICAgICAgc2VsZi5uID0gbGVuKHNlbGYuYWxsaW5rcykKCiAgICBkZWYgbG9hZChzZWxmKToKICAgICAgICBqID0gMAogICAgICAgIHRyeToKICAgICAgICAgICAgd2hpbGUgaiA8PSBzZWxmLm46CiAgICAgICAgICAgICAgICBwYWdlID0gcmVxdWVzdHMuZ2V0KHNlbGYuYWxsaW5rc1tqXSkuY29udGVudC5kZWNvZGUoKQogICAgICAgICAgICAgICAgdHJ1ZV9saW5rID0gcmUuc2VhcmNoKHInKD88PXNyYz1cIikoaHR0cDpcL1wvXGR7MSwzfVwuXGR7MSwzfVxTKykoPz1cIlxzezF9c3QpJywgcGFnZSkuZ3JvdXAoKQogICAgICAgICAgICAgICAgZXh0ID0gcmUuc2VhcmNoKHInKD88PVx3ezF9XC57MX0pKFtqcGduaWZlXXszLDR9KSg/PVxiKScsdHJ1ZV9saW5rKS5ncm91cCgpCiAgICAgICAgICAgICAgICBwaWMgPSByZXF1ZXN0cy5nZXQodHJ1ZV9saW5rKS5jb250ZW50CiAgICAgICAgICAgICAgICB0aW1lLnNsZWVwKDEpCiAgICAgICAgICAgICAgICBmID0gb3BlbihEb3dubG9hZC5yYW5kbmFtZSgxNikrJy4nKyBleHQsJ3diJykKICAgICAgICAgICAgICAgIGYud3JpdGUocGljKQogICAgICAgICAgICAgICAgZi5jbG9zZSgpCiAgICAgICAgICAgICAgICBqKz0xCiAgICAgICAgZXhjZXB0IEluZGV4RXJyb3I6CiAgICAgICAgICAgIHBhc3MKICAgIApkZWYgY29weXBhc3QoZSk6CiAgICBsaz1tYWludy5zZWxlY3Rpb25fZ2V0KHNlbGVjdGlvbj0nQ0xJUEJPQVJEJykKICAgIG15bGluay5pbnNlcnQoMSwgbGspCiAgICAKZGVmIG9wZW5kaXIoKToKICAgIGYgPSBmZC5hc2tkaXJlY3RvcnkoKQogICAgdHJ5OgogICAgICAgIG9zLmNoZGlyKGYpCiAgICBleGNlcHQ6IHBhc3MKCmRlZiBnbygpOgogICAgcyA9IG15bGluay5nZXQoKQogICAgYjIuY29uZmlndXJlKHN0YXRlPSdkaXNhYmxlZCcpCiAgICBteWxpbmsuY29uZmlndXJlKHN0YXRlPSdkaXNhYmxlZCcpCiAgICBkID0gRG93bmxvYWQocykKICAgIGQucmF3bGlua3MoKQogICAgZC5sb2FkKCkKICAgIGIyLmNvbmZpZ3VyZShzdGF0ZT0nbm9ybWFsJykKICAgIG15bGluay5jb25maWd1cmUoc3RhdGU9J25vcm1hbCcpCiAgICBteWxpbmsuZGVsZXRlKDAsRU5EKQoKbWFpbncgPSBUaygpCm1haW53LnRpdGxlKCdnLmUtaGVudGFpLm9yZyBkb3dubG9hZGVyJykKbWFpbncucmVzaXphYmxlKDAsMCkKbWFpbncuZ2VvbWV0cnkoJzMwMHgyNDAnKQoKbXlsaW5rID0gRW50cnkobWFpbncsd2lkdGg9MzApCnRleHQxID0gTGFiZWw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