Kyo-Kai commited on
Commit
f4d52c1
1 Parent(s): fb51feb

Upload 18 files

Browse files
.gitattributes CHANGED
@@ -25,7 +25,6 @@
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
  *.tflite filter=lfs diff=lfs merge=lfs -text
30
  *.tgz filter=lfs diff=lfs merge=lfs -text
31
  *.wasm filter=lfs diff=lfs merge=lfs -text
@@ -33,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
 
28
  *.tflite filter=lfs diff=lfs merge=lfs -text
29
  *.tgz filter=lfs diff=lfs merge=lfs -text
30
  *.wasm filter=lfs diff=lfs merge=lfs -text
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ driver/chromedriver filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ # Install Google Chrome
4
+ RUN apt-get update && apt-get install -y wget gnupg2
5
+ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
6
+ RUN echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
7
+ RUN apt-get update && apt-get install -y google-chrome-stable
8
+
9
+ WORKDIR /code
10
+
11
+ COPY ./requirements.txt /code/requirements.txt
12
+
13
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
14
+
15
+ # Set up a new user named "user" with user ID 1000
16
+ RUN useradd -m -u 1000 user
17
+ # Switch to the "user" user
18
+ USER user
19
+ # Set home to the user's home directory
20
+ ENV HOME=/home/user \
21
+ PATH=/home/user/.local/bin:$PATH
22
+
23
+ # Set the working directory to the user's home directory
24
+ WORKDIR $HOME/app
25
+
26
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
27
+ COPY --chown=user . $HOME/app
28
+
29
+ # Install the ML models
30
+ RUN mkdir -p /home/user/app/cv_files/ && \
31
+ curl -L https://huggingface.co/datasets/Kyo-Kai/Fsg_pp_files/resolve/main/AniClassifier.pt?download=true -o /home/user/app/cv_files/AniClassifier.pt && \
32
+ curl -L https://huggingface.co/datasets/Kyo-Kai/Fsg_pp_files/resolve/main/AniFaceDet.pt?download=true -o /home/user/app/cv_files/AniFaceDet.pt
33
+
34
+ # Give executable permissions to chromedriver
35
+ RUN chmod +x $HOME/app/driver/chromedriver
36
+
37
+ # Run the python file
38
+ CMD ["uvicorn", "Fsg_pp:app", "--host", "0.0.0.0", "--port", "7860"]
Fsg_pp.py ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+ import os
4
+ import commands.exec_path as exec_path
5
+ import commands.driver_instance as driver_instance
6
+ import glob
7
+ import logging
8
+
9
+ from commands.universal import searchQuery
10
+ from ai.autocrop import autoCropImages
11
+ from sites.pixiv import getOrderedPixivImages
12
+ from sites.danbooru import getOrderedDanbooruImages
13
+ from sites.zerochan import getOrderedZerochanImages
14
+ from sites.yandex import getOrderedYandexImages
15
+
16
+
17
+
18
+ logging.basicConfig(level=logging.INFO)
19
+ class ImageGallery:
20
+ def __init__(self):
21
+ self.imgz = []
22
+ self.selected = 0
23
+ self.search_counter = 0
24
+
25
+ def return_images(self, image_locs):
26
+ self.imgz = image_locs
27
+
28
+ total_images = len(glob.glob('./Images/*'))
29
+ if total_images >= 20:
30
+ os.system("rm -r ./Images")
31
+ os.makedirs("./Images")
32
+
33
+ # Log the return value
34
+ logging.info(self.imgz)
35
+ return self.imgz if self.imgz else []
36
+
37
+ def get_select_index(self, evt: gr.SelectData):
38
+ self.selected = evt.index
39
+ return self.selected
40
+
41
+ def send_number(self):
42
+ return self.imgz[int(self.selected)], gr.Tabs(selected=0)
43
+
44
+ # Create an instance of ImageGallery for each tab
45
+ pixiv_gallery = ImageGallery()
46
+ danbooru_gallery = ImageGallery()
47
+ zerochan_gallery = ImageGallery()
48
+ yandex_gallery = ImageGallery()
49
+
50
+
51
+ # Helper functions
52
+ def pix_imgs(searchQuery, num_pics, num_pages,searchTypes,viewRestriction,imageControl,n_likes, n_bookmarks, n_views,
53
+ start_date, end_date, user_name, pass_word):
54
+ driver = driver_instance.create_driver(profile=1)
55
+ return pixiv_gallery.return_images(getOrderedPixivImages(driver=driver, exec_path=exec_path, user_search=searchQuery, num_pics=num_pics, num_pages=num_pages,searchTypes=searchTypes,viewRestriction=viewRestriction,imageControl=imageControl, n_likes=n_likes, n_bookmarks=n_bookmarks,
56
+ n_views=n_views, start_date=start_date,end_date=end_date, user_name=user_name, pass_word=pass_word))
57
+
58
+ def danb_imgs(searchQuery, num_pics, num_pages, filters, bl_tags, inc_tags,imageControl):
59
+ driver = driver_instance.create_driver()
60
+ return danbooru_gallery.return_images(getOrderedDanbooruImages(driver=driver, user_search=searchQuery, num_pics=num_pics, num_pages=num_pages, filters=filters, bl_tags=bl_tags, inc_tags=inc_tags, exec_path=exec_path,imageControl=imageControl))
61
+
62
+ def zero_imgs(searchQuery, num_pics, num_pages, n_likes, filters,imageControl):
63
+ driver = driver_instance.create_driver()
64
+ return zerochan_gallery.return_images(getOrderedZerochanImages(driver=driver, exec_path=exec_path, user_search=searchQuery, num_pics=num_pics, num_pages=num_pages, n_likes=n_likes, filters=filters,imageControl=imageControl))
65
+
66
+ def yandex_imgs(searchQuery, num_pics, filters,imageOrientation):
67
+ driver = driver_instance.create_driver()
68
+ return yandex_gallery.return_images(getOrderedYandexImages(driver=driver, exec_path=exec_path, user_search=searchQuery, num_pics=num_pics, filters=filters,imageOrientation=imageOrientation))
69
+
70
+
71
+
72
+ # Feature Functions
73
+ def open_folder(folder_path, mode=0):
74
+ folder_opened = os.path.abspath(folder_path)
75
+ if mode:
76
+ folder_opened = os.path.abspath(os.path.join(folder_path, "cropped"))
77
+ os.system(f'open "{folder_opened}"' if os.name == 'posix' else f'explorer "{folder_opened}"')
78
+
79
+ def cropImages(image,crop_scale_factor):
80
+ return autoCropImages(image,crop_scale_factor)
81
+
82
+ def create_gallery_tab(tab_name, search_fn, search_inputs, gallery_instance, fn_on_click):
83
+ with gr.Column():
84
+ gallery=gr.Gallery(label="Image Preview", preview=True, object_fit="cover", container=True, columns=5)
85
+
86
+ with gr.Row():
87
+ crop_btn = gr.Button(value="Crop Selected Image",variant='secondary')
88
+ crop_btn.click(fn=fn_on_click, outputs=[image,tabs])
89
+ open_btn = gr.Button(value="Open 📁",variant='secondary')
90
+ open_btn.click(fn=open_folder, inputs=folder_input)
91
+
92
+ with gr.Row():
93
+ gr.HTML('''<div>
94
+ <p style="margin-top: 20px; font-size: 1.25rem;">For testing purposes only. AI mode is set to be always on even if unchecked. You will experience lag due to hosting limitations, also due to extra throttling imposed</p>
95
+ <p style="font-size: 1.25rem;">For the full experience, please check out the GitHub page:</p>
96
+ <p style="font-size: 1.25rem;"><a href="https://github.com/EngMarchG/Fsg-Pp">Fsg-Pp - Finally Some Good Profile Pictures</a></p>
97
+ </div>''')
98
+
99
+ gallery.select(gallery_instance.get_select_index, None)
100
+ green_btn.click(search_fn, search_inputs, outputs=gallery)
101
+
102
+
103
+ # Main Layout of the GUI
104
+ with gr.Blocks(css='style.css') as demo:
105
+ with gr.Tabs(selected=1) as tabs:
106
+ folder_input = gr.Textbox(value="./Images/", label="Enter Folder Path", visible=False)
107
+
108
+ # Automatic Crop Tab
109
+ with gr.TabItem("Automatic Crop", id=0):
110
+ with gr.Row():
111
+ with gr.Column():
112
+ image = gr.Image(type="filepath")
113
+ crop_scale_factor = gr.Slider(0.5,3, value=1.2,step=0.1, label="Crop Scale Factor")
114
+ with gr.Column():
115
+ outputImages = gr.Gallery(label="Cropped Image Preview", preview=True, object_fit="cover", container=True)
116
+
117
+ with gr.Row():
118
+ green_btn = gr.Button(value="Crop Image", size='sm')
119
+ green_btn.click(cropImages, [image,crop_scale_factor],outputs=outputImages)
120
+ open_btn = gr.Button(value="Open 📁",variant='secondary', size='sm')
121
+ open_btn.click(fn=open_folder, inputs=[folder_input,crop_scale_factor])
122
+ with gr.Row():
123
+ gr.HTML('''<div>
124
+ <p style="margin-top: 20px; font-size: 1.25rem;">For testing purposes only. AI mode is set to be always on even if unchecked. You will experience lag due to hosting limitations, also due to extra throttling imposed</p>
125
+ <p style="font-size: 1.25rem;">For the full experience, please check out the GitHub page:</p>
126
+ <p style="font-size: 1.25rem;"><a href="https://github.com/EngMarchG/Fsg-Pp">Fsg-Pp - Finally Some Good Profile Pictures</a></p>
127
+ </div>''')
128
+
129
+
130
+ # Pixiv Tab
131
+ with gr.TabItem("Pixiv", id=1):
132
+ with gr.Row():
133
+ with gr.Column():
134
+ searchQuery = gr.Textbox(label="Search Query", placeholder="Suggested to use the char's full name")
135
+ with gr.Row():
136
+ num_pics = gr.Slider(1,4, value=2, step=int, label="Number of Pictures")
137
+ with gr.Row():
138
+ num_pages = gr.Slider(1,3, value=1, step=int, label="Number of Pages")
139
+ with gr.Row():
140
+ with gr.Column():
141
+ with gr.Row():
142
+ searchTypes = gr.CheckboxGroup(["Premium Search","Freemium"], value=["Freemium"], label="Search Type", type="index", elem_id="pixiv")
143
+ with gr.Row():
144
+ viewRestriction = gr.CheckboxGroup(["PG","R-18"],label="Viewing Restriction (Default: Account Settings)",type="index",elem_id="viewing-restrictions")
145
+ with gr.Row(elem_id='button-row'):
146
+ green_btn = gr.Button(value="Search")
147
+ with gr.Row():
148
+ imageControl = gr.CheckboxGroup(["Full Res", "Continue Search","Search by Oldest", "AI Classifier"], value=["Full Res"], label="Image Control", type="index",elem_id="pixiv-filters")
149
+ with gr.Row():
150
+ with gr.Row():
151
+ n_likes = gr.Number(value=0, label="Filter by Likes")
152
+ with gr.Row():
153
+ n_bookmarks = gr.Number(value=0, label="Filter by Bookmarks")
154
+ with gr.Row():
155
+ n_views = gr.Number(value=0, label="Filter by Views")
156
+ with gr.Row():
157
+ start_date = gr.Textbox(label="Start date", placeholder=("2016-01-22 YEAR-MONTH-DAY"))
158
+ with gr.Row():
159
+ end_date = gr.Textbox(label="End date", placeholder=("2022-09-22 YEAR-MONTH-DAY"))
160
+ with gr.Row():
161
+ user_name = gr.Textbox(label="Email", type="email")
162
+ with gr.Row():
163
+ pass_word = gr.Textbox(label="Password", type="password")
164
+
165
+ pixiv_inputs = [searchQuery, num_pics, num_pages,searchTypes,viewRestriction,imageControl,n_likes, n_bookmarks, n_views,
166
+ start_date,end_date, user_name, pass_word]
167
+ create_gallery_tab("Pixiv", pix_imgs, pixiv_inputs, pixiv_gallery, pixiv_gallery.send_number)
168
+
169
+
170
+ # Danbooru Tab
171
+ with gr.TabItem("Danbooru", id=2):
172
+ with gr.Row():
173
+ with gr.Column():
174
+ searchQuery = gr.Textbox(label="Search Query", placeholder="Suggested to use the char's full name")
175
+ with gr.Row():
176
+ num_pics = gr.Slider(1,4, value=2, step=int, label="Number of Pictures")
177
+ with gr.Row():
178
+ num_pages = gr.Slider(1,3, value=1, step=int, label="Number of Pages")
179
+ with gr.Row():
180
+ filters = gr.CheckboxGroup(["Score", "Exact Match", "More PG", "Sensitive", "Strictly PG", "AI Classifier"], label="Filters", type="index", elem_id="filtering")
181
+ with gr.Row():
182
+ imageControl = gr.CheckboxGroup(["Continue Search"], label="Image Control", type="index", elem_id="imageControl")
183
+ with gr.Row():
184
+ bl_tags = gr.Textbox(label="Tags to Filter", placeholder=("Add stuff like typical undergarments etc to ensure complete pg friendliness"),lines=2)
185
+ with gr.Row():
186
+ inc_tags = gr.Textbox(label="Tags to Include", placeholder=("1girl, 1boy for profile pictures"))
187
+ green_btn = gr.Button(value="Search")
188
+
189
+ danbooru_inputs = [searchQuery, num_pics, num_pages, filters, bl_tags, inc_tags,imageControl]
190
+ create_gallery_tab("Danbooru", danb_imgs, danbooru_inputs, danbooru_gallery, danbooru_gallery.send_number)
191
+
192
+
193
+ # Zerochan Tab
194
+ with gr.TabItem("Zerochan", id=3):
195
+ with gr.Row():
196
+ with gr.Column():
197
+ searchQuery = gr.Textbox(label="Search Query", placeholder="Suggested to use the char's full name")
198
+ with gr.Row():
199
+ num_pics = gr.Slider(1,4, value=2, step=int, label="Number of Pictures")
200
+ with gr.Row():
201
+ num_pages = gr.Slider(1,3, value=1, step=int, label="Number of Pages")
202
+ with gr.Row():
203
+ with gr.Row():
204
+ n_likes = gr.Number(value=0, label="Filter by Likes")
205
+ with gr.Row():
206
+ filters = gr.CheckboxGroup(["AI Classifier"], label="Filters", type="index",elem_id="zeroAIhover")
207
+ with gr.Column():
208
+ imageControl = gr.CheckboxGroup(["Continue Search"], label="Image Control", type="index", elem_id="imageControl")
209
+ green_btn = gr.Button(value="Search")
210
+
211
+ with gr.Column():
212
+ zerochan_inputs = [searchQuery, num_pics, num_pages, n_likes, filters,imageControl]
213
+ create_gallery_tab("Zerochan", zero_imgs, zerochan_inputs, zerochan_gallery, zerochan_gallery.send_number)
214
+
215
+
216
+ # Yandex Tab
217
+ with gr.TabItem("Yandex", id=4):
218
+ with gr.Row():
219
+ with gr.Column():
220
+ searchQuery = gr.Textbox(label="Search Query", placeholder="Suggested to use the char's full name")
221
+ with gr.Row():
222
+ num_pics = gr.Slider(1,10, value=2, step=int, label="Number of Pictures")
223
+ with gr.Row():
224
+ with gr.Row():
225
+ filters = gr.CheckboxGroup(["AI Classifier","Search By Recent"], label="Filters", type="index",elem_id="zeroAIhover")
226
+ with gr.Column():
227
+ imageOrientation = gr.Radio(["Landscape","Portrait","Square"], label="Image Orientation", type="index", elem_id="imageControl")
228
+ green_btn = gr.Button(value="Search")
229
+
230
+ yandex_inputs = [searchQuery, num_pics, filters,imageOrientation]
231
+ create_gallery_tab("Yandex", yandex_imgs, yandex_inputs, yandex_gallery, yandex_gallery.send_number)
232
+
233
+
234
+
235
+ demo.launch(demo.launch(server_name="0.0.0.0", server_port=7860))
Images/test.txt ADDED
File without changes
LICENSE ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ When we speak of free software, we are referring to freedom, not
21
+ price. Our General Public Licenses are designed to make sure that you
22
+ have the freedom to distribute copies of free software (and charge for
23
+ them if you wish), that you receive source code or can get it if you
24
+ want it, that you can change the software or use pieces of it in new
25
+ free programs, and that you know you can do these things.
26
+
27
+ Developers that use our General Public Licenses protect your rights
28
+ with two steps: (1) assert copyright on the software, and (2) offer
29
+ you this License which gives you legal permission to copy, distribute
30
+ and/or modify the software.
31
+
32
+ A secondary benefit of defending all users' freedom is that
33
+ improvements made in alternate versions of the program, if they
34
+ receive widespread use, become available for other developers to
35
+ incorporate. Many developers of free software are heartened and
36
+ encouraged by the resulting cooperation. However, in the case of
37
+ software used on network servers, this result may fail to come about.
38
+ The GNU General Public License permits making a modified version and
39
+ letting the public access it on a server without ever releasing its
40
+ source code to the public.
41
+
42
+ The GNU Affero General Public License is designed specifically to
43
+ ensure that, in such cases, the modified source code becomes available
44
+ to the community. It requires the operator of a network server to
45
+ provide the source code of the modified version running there to the
46
+ users of that server. Therefore, public use of a modified version, on
47
+ a publicly accessible server, gives the public access to the source
48
+ code of the modified version.
49
+
50
+ An older license, called the Affero General Public License and
51
+ published by Affero, was designed to accomplish similar goals. This is
52
+ a different license, not a version of the Affero GPL, but Affero has
53
+ released a new version of the Affero GPL which permits relicensing under
54
+ this license.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ TERMS AND CONDITIONS
60
+
61
+ 0. Definitions.
62
+
63
+ "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+ "Copyright" also means copyright-like laws that apply to other kinds of
66
+ works, such as semiconductor masks.
67
+
68
+ "The Program" refers to any copyrightable work licensed under this
69
+ License. Each licensee is addressed as "you". "Licensees" and
70
+ "recipients" may be individuals or organizations.
71
+
72
+ To "modify" a work means to copy from or adapt all or part of the work
73
+ in a fashion requiring copyright permission, other than the making of an
74
+ exact copy. The resulting work is called a "modified version" of the
75
+ earlier work or a work "based on" the earlier work.
76
+
77
+ A "covered work" means either the unmodified Program or a work based
78
+ on the Program.
79
+
80
+ To "propagate" a work means to do anything with it that, without
81
+ permission, would make you directly or secondarily liable for
82
+ infringement under applicable copyright law, except executing it on a
83
+ computer or modifying a private copy. Propagation includes copying,
84
+ distribution (with or without modification), making available to the
85
+ public, and in some countries other activities as well.
86
+
87
+ To "convey" a work means any kind of propagation that enables other
88
+ parties to make or receive copies. Mere interaction with a user through
89
+ a computer network, with no transfer of a copy, is not conveying.
90
+
91
+ An interactive user interface displays "Appropriate Legal Notices"
92
+ to the extent that it includes a convenient and prominently visible
93
+ feature that (1) displays an appropriate copyright notice, and (2)
94
+ tells the user that there is no warranty for the work (except to the
95
+ extent that warranties are provided), that licensees may convey the
96
+ work under this License, and how to view a copy of this License. If
97
+ the interface presents a list of user commands or options, such as a
98
+ menu, a prominent item in the list meets this criterion.
99
+
100
+ 1. Source Code.
101
+
102
+ The "source code" for a work means the preferred form of the work
103
+ for making modifications to it. "Object code" means any non-source
104
+ form of a work.
105
+
106
+ A "Standard Interface" means an interface that either is an official
107
+ standard defined by a recognized standards body, or, in the case of
108
+ interfaces specified for a particular programming language, one that
109
+ is widely used among developers working in that language.
110
+
111
+ The "System Libraries" of an executable work include anything, other
112
+ than the work as a whole, that (a) is included in the normal form of
113
+ packaging a Major Component, but which is not part of that Major
114
+ Component, and (b) serves only to enable use of the work with that
115
+ Major Component, or to implement a Standard Interface for which an
116
+ implementation is available to the public in source code form. A
117
+ "Major Component", in this context, means a major essential component
118
+ (kernel, window system, and so on) of the specific operating system
119
+ (if any) on which the executable work runs, or a compiler used to
120
+ produce the work, or an object code interpreter used to run it.
121
+
122
+ The "Corresponding Source" for a work in object code form means all
123
+ the source code needed to generate, install, and (for an executable
124
+ work) run the object code and to modify the work, including scripts to
125
+ control those activities. However, it does not include the work's
126
+ System Libraries, or general-purpose tools or generally available free
127
+ programs which are used unmodified in performing those activities but
128
+ which are not part of the work. For example, Corresponding Source
129
+ includes interface definition files associated with source files for
130
+ the work, and the source code for shared libraries and dynamically
131
+ linked subprograms that the work is specifically designed to require,
132
+ such as by intimate data communication or control flow between those
133
+ subprograms and other parts of the work.
134
+
135
+ The Corresponding Source need not include anything that users
136
+ can regenerate automatically from other parts of the Corresponding
137
+ Source.
138
+
139
+ The Corresponding Source for a work in source code form is that
140
+ same work.
141
+
142
+ 2. Basic Permissions.
143
+
144
+ All rights granted under this License are granted for the term of
145
+ copyright on the Program, and are irrevocable provided the stated
146
+ conditions are met. This License explicitly affirms your unlimited
147
+ permission to run the unmodified Program. The output from running a
148
+ covered work is covered by this License only if the output, given its
149
+ content, constitutes a covered work. This License acknowledges your
150
+ rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+ You may make, run and propagate covered works that you do not
153
+ convey, without conditions so long as your license otherwise remains
154
+ in force. You may convey covered works to others for the sole purpose
155
+ of having them make modifications exclusively for you, or provide you
156
+ with facilities for running those works, provided that you comply with
157
+ the terms of this License in conveying all material for which you do
158
+ not control copyright. Those thus making or running the covered works
159
+ for you must do so exclusively on your behalf, under your direction
160
+ and control, on terms that prohibit them from making any copies of
161
+ your copyrighted material outside their relationship with you.
162
+
163
+ Conveying under any other circumstances is permitted solely under
164
+ the conditions stated below. Sublicensing is not allowed; section 10
165
+ makes it unnecessary.
166
+
167
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+ No covered work shall be deemed part of an effective technological
170
+ measure under any applicable law fulfilling obligations under article
171
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+ similar laws prohibiting or restricting circumvention of such
173
+ measures.
174
+
175
+ When you convey a covered work, you waive any legal power to forbid
176
+ circumvention of technological measures to the extent such circumvention
177
+ is effected by exercising rights under this License with respect to
178
+ the covered work, and you disclaim any intention to limit operation or
179
+ modification of the work as a means of enforcing, against the work's
180
+ users, your or third parties' legal rights to forbid circumvention of
181
+ technological measures.
182
+
183
+ 4. Conveying Verbatim Copies.
184
+
185
+ You may convey verbatim copies of the Program's source code as you
186
+ receive it, in any medium, provided that you conspicuously and
187
+ appropriately publish on each copy an appropriate copyright notice;
188
+ keep intact all notices stating that this License and any
189
+ non-permissive terms added in accord with section 7 apply to the code;
190
+ keep intact all notices of the absence of any warranty; and give all
191
+ recipients a copy of this License along with the Program.
192
+
193
+ You may charge any price or no price for each copy that you convey,
194
+ and you may offer support or warranty protection for a fee.
195
+
196
+ 5. Conveying Modified Source Versions.
197
+
198
+ You may convey a work based on the Program, or the modifications to
199
+ produce it from the Program, in the form of source code under the
200
+ terms of section 4, provided that you also meet all of these conditions:
201
+
202
+ a) The work must carry prominent notices stating that you modified
203
+ it, and giving a relevant date.
204
+
205
+ b) The work must carry prominent notices stating that it is
206
+ released under this License and any conditions added under section
207
+ 7. This requirement modifies the requirement in section 4 to
208
+ "keep intact all notices".
209
+
210
+ c) You must license the entire work, as a whole, under this
211
+ License to anyone who comes into possession of a copy. This
212
+ License will therefore apply, along with any applicable section 7
213
+ additional terms, to the whole of the work, and all its parts,
214
+ regardless of how they are packaged. This License gives no
215
+ permission to license the work in any other way, but it does not
216
+ invalidate such permission if you have separately received it.
217
+
218
+ d) If the work has interactive user interfaces, each must display
219
+ Appropriate Legal Notices; however, if the Program has interactive
220
+ interfaces that do not display Appropriate Legal Notices, your
221
+ work need not make them do so.
222
+
223
+ A compilation of a covered work with other separate and independent
224
+ works, which are not by their nature extensions of the covered work,
225
+ and which are not combined with it such as to form a larger program,
226
+ in or on a volume of a storage or distribution medium, is called an
227
+ "aggregate" if the compilation and its resulting copyright are not
228
+ used to limit the access or legal rights of the compilation's users
229
+ beyond what the individual works permit. Inclusion of a covered work
230
+ in an aggregate does not cause this License to apply to the other
231
+ parts of the aggregate.
232
+
233
+ 6. Conveying Non-Source Forms.
234
+
235
+ You may convey a covered work in object code form under the terms
236
+ of sections 4 and 5, provided that you also convey the
237
+ machine-readable Corresponding Source under the terms of this License,
238
+ in one of these ways:
239
+
240
+ a) Convey the object code in, or embodied in, a physical product
241
+ (including a physical distribution medium), accompanied by the
242
+ Corresponding Source fixed on a durable physical medium
243
+ customarily used for software interchange.
244
+
245
+ b) Convey the object code in, or embodied in, a physical product
246
+ (including a physical distribution medium), accompanied by a
247
+ written offer, valid for at least three years and valid for as
248
+ long as you offer spare parts or customer support for that product
249
+ model, to give anyone who possesses the object code either (1) a
250
+ copy of the Corresponding Source for all the software in the
251
+ product that is covered by this License, on a durable physical
252
+ medium customarily used for software interchange, for a price no
253
+ more than your reasonable cost of physically performing this
254
+ conveying of source, or (2) access to copy the
255
+ Corresponding Source from a network server at no charge.
256
+
257
+ c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+
263
+ d) Convey the object code by offering access from a designated
264
+ place (gratis or for a charge), and offer equivalent access to the
265
+ Corresponding Source in the same way through the same place at no
266
+ further charge. You need not require recipients to copy the
267
+ Corresponding Source along with the object code. If the place to
268
+ copy the object code is a network server, the Corresponding Source
269
+ may be on a different server (operated by you or a third party)
270
+ that supports equivalent copying facilities, provided you maintain
271
+ clear directions next to the object code saying where to find the
272
+ Corresponding Source. Regardless of what server hosts the
273
+ Corresponding Source, you remain obligated to ensure that it is
274
+ available for as long as needed to satisfy these requirements.
275
+
276
+ e) Convey the object code using peer-to-peer transmission, provided
277
+ you inform other peers where the object code and Corresponding
278
+ Source of the work are being offered to the general public at no
279
+ charge under subsection 6d.
280
+
281
+ A separable portion of the object code, whose source code is excluded
282
+ from the Corresponding Source as a System Library, need not be
283
+ included in conveying the object code work.
284
+
285
+ A "User Product" is either (1) a "consumer product", which means any
286
+ tangible personal property which is normally used for personal, family,
287
+ or household purposes, or (2) anything designed or sold for incorporation
288
+ into a dwelling. In determining whether a product is a consumer product,
289
+ doubtful cases shall be resolved in favor of coverage. For a particular
290
+ product received by a particular user, "normally used" refers to a
291
+ typical or common use of that class of product, regardless of the status
292
+ of the particular user or of the way in which the particular user
293
+ actually uses, or expects or is expected to use, the product. A product
294
+ is a consumer product regardless of whether the product has substantial
295
+ commercial, industrial or non-consumer uses, unless such uses represent
296
+ the only significant mode of use of the product.
297
+
298
+ "Installation Information" for a User Product means any methods,
299
+ procedures, authorization keys, or other information required to install
300
+ and execute modified versions of a covered work in that User Product from
301
+ a modified version of its Corresponding Source. The information must
302
+ suffice to ensure that the continued functioning of the modified object
303
+ code is in no case prevented or interfered with solely because
304
+ modification has been made.
305
+
306
+ If you convey an object code work under this section in, or with, or
307
+ specifically for use in, a User Product, and the conveying occurs as
308
+ part of a transaction in which the right of possession and use of the
309
+ User Product is transferred to the recipient in perpetuity or for a
310
+ fixed term (regardless of how the transaction is characterized), the
311
+ Corresponding Source conveyed under this section must be accompanied
312
+ by the Installation Information. But this requirement does not apply
313
+ if neither you nor any third party retains the ability to install
314
+ modified object code on the User Product (for example, the work has
315
+ been installed in ROM).
316
+
317
+ The requirement to provide Installation Information does not include a
318
+ requirement to continue to provide support service, warranty, or updates
319
+ for a work that has been modified or installed by the recipient, or for
320
+ the User Product in which it has been modified or installed. Access to a
321
+ network may be denied when the modification itself materially and
322
+ adversely affects the operation of the network or violates the rules and
323
+ protocols for communication across the network.
324
+
325
+ Corresponding Source conveyed, and Installation Information provided,
326
+ in accord with this section must be in a format that is publicly
327
+ documented (and with an implementation available to the public in
328
+ source code form), and must require no special password or key for
329
+ unpacking, reading or copying.
330
+
331
+ 7. Additional Terms.
332
+
333
+ "Additional permissions" are terms that supplement the terms of this
334
+ License by making exceptions from one or more of its conditions.
335
+ Additional permissions that are applicable to the entire Program shall
336
+ be treated as though they were included in this License, to the extent
337
+ that they are valid under applicable law. If additional permissions
338
+ apply only to part of the Program, that part may be used separately
339
+ under those permissions, but the entire Program remains governed by
340
+ this License without regard to the additional permissions.
341
+
342
+ When you convey a copy of a covered work, you may at your option
343
+ remove any additional permissions from that copy, or from any part of
344
+ it. (Additional permissions may be written to require their own
345
+ removal in certain cases when you modify the work.) You may place
346
+ additional permissions on material, added by you to a covered work,
347
+ for which you have or can give appropriate copyright permission.
348
+
349
+ Notwithstanding any other provision of this License, for material you
350
+ add to a covered work, you may (if authorized by the copyright holders of
351
+ that material) supplement the terms of this License with terms:
352
+
353
+ a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+
356
+ b) Requiring preservation of specified reasonable legal notices or
357
+ author attributions in that material or in the Appropriate Legal
358
+ Notices displayed by works containing it; or
359
+
360
+ c) Prohibiting misrepresentation of the origin of that material, or
361
+ requiring that modified versions of such material be marked in
362
+ reasonable ways as different from the original version; or
363
+
364
+ d) Limiting the use for publicity purposes of names of licensors or
365
+ authors of the material; or
366
+
367
+ e) Declining to grant rights under trademark law for use of some
368
+ trade names, trademarks, or service marks; or
369
+
370
+ f) Requiring indemnification of licensors and authors of that
371
+ material by anyone who conveys the material (or modified versions of
372
+ it) with contractual assumptions of liability to the recipient, for
373
+ any liability that these contractual assumptions directly impose on
374
+ those licensors and authors.
375
+
376
+ All other non-permissive additional terms are considered "further
377
+ restrictions" within the meaning of section 10. If the Program as you
378
+ received it, or any part of it, contains a notice stating that it is
379
+ governed by this License along with a term that is a further
380
+ restriction, you may remove that term. If a license document contains
381
+ a further restriction but permits relicensing or conveying under this
382
+ License, you may add to a covered work material governed by the terms
383
+ of that license document, provided that the further restriction does
384
+ not survive such relicensing or conveying.
385
+
386
+ If you add terms to a covered work in accord with this section, you
387
+ must place, in the relevant source files, a statement of the
388
+ additional terms that apply to those files, or a notice indicating
389
+ where to find the applicable terms.
390
+
391
+ Additional terms, permissive or non-permissive, may be stated in the
392
+ form of a separately written license, or stated as exceptions;
393
+ the above requirements apply either way.
394
+
395
+ 8. Termination.
396
+
397
+ You may not propagate or modify a covered work except as expressly
398
+ provided under this License. Any attempt otherwise to propagate or
399
+ modify it is void, and will automatically terminate your rights under
400
+ this License (including any patent licenses granted under the third
401
+ paragraph of section 11).
402
+
403
+ However, if you cease all violation of this License, then your
404
+ license from a particular copyright holder is reinstated (a)
405
+ provisionally, unless and until the copyright holder explicitly and
406
+ finally terminates your license, and (b) permanently, if the copyright
407
+ holder fails to notify you of the violation by some reasonable means
408
+ prior to 60 days after the cessation.
409
+
410
+ Moreover, your license from a particular copyright holder is
411
+ reinstated permanently if the copyright holder notifies you of the
412
+ violation by some reasonable means, this is the first time you have
413
+ received notice of violation of this License (for any work) from that
414
+ copyright holder, and you cure the violation prior to 30 days after
415
+ your receipt of the notice.
416
+
417
+ Termination of your rights under this section does not terminate the
418
+ licenses of parties who have received copies or rights from you under
419
+ this License. If your rights have been terminated and not permanently
420
+ reinstated, you do not qualify to receive new licenses for the same
421
+ material under section 10.
422
+
423
+ 9. Acceptance Not Required for Having Copies.
424
+
425
+ You are not required to accept this License in order to receive or
426
+ run a copy of the Program. Ancillary propagation of a covered work
427
+ occurring solely as a consequence of using peer-to-peer transmission
428
+ to receive a copy likewise does not require acceptance. However,
429
+ nothing other than this License grants you permission to propagate or
430
+ modify any covered work. These actions infringe copyright if you do
431
+ not accept this License. Therefore, by modifying or propagating a
432
+ covered work, you indicate your acceptance of this License to do so.
433
+
434
+ 10. Automatic Licensing of Downstream Recipients.
435
+
436
+ Each time you convey a covered work, the recipient automatically
437
+ receives a license from the original licensors, to run, modify and
438
+ propagate that work, subject to this License. You are not responsible
439
+ for enforcing compliance by third parties with this License.
440
+
441
+ An "entity transaction" is a transaction transferring control of an
442
+ organization, or substantially all assets of one, or subdividing an
443
+ organization, or merging organizations. If propagation of a covered
444
+ work results from an entity transaction, each party to that
445
+ transaction who receives a copy of the work also receives whatever
446
+ licenses to the work the party's predecessor in interest had or could
447
+ give under the previous paragraph, plus a right to possession of the
448
+ Corresponding Source of the work from the predecessor in interest, if
449
+ the predecessor has it or can get it with reasonable efforts.
450
+
451
+ You may not impose any further restrictions on the exercise of the
452
+ rights granted or affirmed under this License. For example, you may
453
+ not impose a license fee, royalty, or other charge for exercise of
454
+ rights granted under this License, and you may not initiate litigation
455
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
456
+ any patent claim is infringed by making, using, selling, offering for
457
+ sale, or importing the Program or any portion of it.
458
+
459
+ 11. Patents.
460
+
461
+ A "contributor" is a copyright holder who authorizes use under this
462
+ License of the Program or a work on which the Program is based. The
463
+ work thus licensed is called the contributor's "contributor version".
464
+
465
+ A contributor's "essential patent claims" are all patent claims
466
+ owned or controlled by the contributor, whether already acquired or
467
+ hereafter acquired, that would be infringed by some manner, permitted
468
+ by this License, of making, using, or selling its contributor version,
469
+ but do not include claims that would be infringed only as a
470
+ consequence of further modification of the contributor version. For
471
+ purposes of this definition, "control" includes the right to grant
472
+ patent sublicenses in a manner consistent with the requirements of
473
+ this License.
474
+
475
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+ patent license under the contributor's essential patent claims, to
477
+ make, use, sell, offer for sale, import and otherwise run, modify and
478
+ propagate the contents of its contributor version.
479
+
480
+ In the following three paragraphs, a "patent license" is any express
481
+ agreement or commitment, however denominated, not to enforce a patent
482
+ (such as an express permission to practice a patent or covenant not to
483
+ sue for patent infringement). To "grant" such a patent license to a
484
+ party means to make such an agreement or commitment not to enforce a
485
+ patent against the party.
486
+
487
+ If you convey a covered work, knowingly relying on a patent license,
488
+ and the Corresponding Source of the work is not available for anyone
489
+ to copy, free of charge and under the terms of this License, through a
490
+ publicly available network server or other readily accessible means,
491
+ then you must either (1) cause the Corresponding Source to be so
492
+ available, or (2) arrange to deprive yourself of the benefit of the
493
+ patent license for this particular work, or (3) arrange, in a manner
494
+ consistent with the requirements of this License, to extend the patent
495
+ license to downstream recipients. "Knowingly relying" means you have
496
+ actual knowledge that, but for the patent license, your conveying the
497
+ covered work in a country, or your recipient's use of the covered work
498
+ in a country, would infringe one or more identifiable patents in that
499
+ country that you have reason to believe are valid.
500
+
501
+ If, pursuant to or in connection with a single transaction or
502
+ arrangement, you convey, or propagate by procuring conveyance of, a
503
+ covered work, and grant a patent license to some of the parties
504
+ receiving the covered work authorizing them to use, propagate, modify
505
+ or convey a specific copy of the covered work, then the patent license
506
+ you grant is automatically extended to all recipients of the covered
507
+ work and works based on it.
508
+
509
+ A patent license is "discriminatory" if it does not include within
510
+ the scope of its coverage, prohibits the exercise of, or is
511
+ conditioned on the non-exercise of one or more of the rights that are
512
+ specifically granted under this License. You may not convey a covered
513
+ work if you are a party to an arrangement with a third party that is
514
+ in the business of distributing software, under which you make payment
515
+ to the third party based on the extent of your activity of conveying
516
+ the work, and under which the third party grants, to any of the
517
+ parties who would receive the covered work from you, a discriminatory
518
+ patent license (a) in connection with copies of the covered work
519
+ conveyed by you (or copies made from those copies), or (b) primarily
520
+ for and in connection with specific products or compilations that
521
+ contain the covered work, unless you entered into that arrangement,
522
+ or that patent license was granted, prior to 28 March 2007.
523
+
524
+ Nothing in this License shall be construed as excluding or limiting
525
+ any implied license or other defenses to infringement that may
526
+ otherwise be available to you under applicable patent law.
527
+
528
+ 12. No Surrender of Others' Freedom.
529
+
530
+ If conditions are imposed on you (whether by court order, agreement or
531
+ otherwise) that contradict the conditions of this License, they do not
532
+ excuse you from the conditions of this License. If you cannot convey a
533
+ covered work so as to satisfy simultaneously your obligations under this
534
+ License and any other pertinent obligations, then as a consequence you may
535
+ not convey it at all. For example, if you agree to terms that obligate you
536
+ to collect a royalty for further conveying from those to whom you convey
537
+ the Program, the only way you could satisfy both those terms and this
538
+ License would be to refrain entirely from conveying the Program.
539
+
540
+ 13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+ Notwithstanding any other provision of this License, if you modify the
543
+ Program, your modified version must prominently offer all users
544
+ interacting with it remotely through a computer network (if your version
545
+ supports such interaction) an opportunity to receive the Corresponding
546
+ Source of your version by providing access to the Corresponding Source
547
+ from a network server at no charge, through some standard or customary
548
+ means of facilitating copying of software. This Corresponding Source
549
+ shall include the Corresponding Source for any work covered by version 3
550
+ of the GNU General Public License that is incorporated pursuant to the
551
+ following paragraph.
552
+
553
+ Notwithstanding any other provision of this License, you have
554
+ permission to link or combine any covered work with a work licensed
555
+ under version 3 of the GNU General Public License into a single
556
+ combined work, and to convey the resulting work. The terms of this
557
+ License will continue to apply to the part which is the covered work,
558
+ but the work with which it is combined will remain governed by version
559
+ 3 of the GNU General Public License.
560
+
561
+ 14. Revised Versions of this License.
562
+
563
+ The Free Software Foundation may publish revised and/or new versions of
564
+ the GNU Affero General Public License from time to time. Such new versions
565
+ will be similar in spirit to the present version, but may differ in detail to
566
+ address new problems or concerns.
567
+
568
+ Each version is given a distinguishing version number. If the
569
+ Program specifies that a certain numbered version of the GNU Affero General
570
+ Public License "or any later version" applies to it, you have the
571
+ option of following the terms and conditions either of that numbered
572
+ version or of any later version published by the Free Software
573
+ Foundation. If the Program does not specify a version number of the
574
+ GNU Affero General Public License, you may choose any version ever published
575
+ by the Free Software Foundation.
576
+
577
+ If the Program specifies that a proxy can decide which future
578
+ versions of the GNU Affero General Public License can be used, that proxy's
579
+ public statement of acceptance of a version permanently authorizes you
580
+ to choose that version for the Program.
581
+
582
+ Later license versions may give you additional or different
583
+ permissions. However, no additional obligations are imposed on any
584
+ author or copyright holder as a result of your choosing to follow a
585
+ later version.
586
+
587
+ 15. Disclaimer of Warranty.
588
+
589
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+ 16. Limitation of Liability.
599
+
600
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+ SUCH DAMAGES.
609
+
610
+ 17. Interpretation of Sections 15 and 16.
611
+
612
+ If the disclaimer of warranty and limitation of liability provided
613
+ above cannot be given local legal effect according to their terms,
614
+ reviewing courts shall apply local law that most closely approximates
615
+ an absolute waiver of all civil liability in connection with the
616
+ Program, unless a warranty or assumption of liability accompanies a
617
+ copy of the Program in return for a fee.
618
+
619
+ END OF TERMS AND CONDITIONS
620
+
621
+ How to Apply These Terms to Your New Programs
622
+
623
+ If you develop a new program, and you want it to be of the greatest
624
+ possible use to the public, the best way to achieve this is to make it
625
+ free software which everyone can redistribute and change under these terms.
626
+
627
+ To do so, attach the following notices to the program. It is safest
628
+ to attach them to the start of each source file to most effectively
629
+ state the exclusion of warranty; and each file should have at least
630
+ the "copyright" line and a pointer to where the full notice is found.
631
+
632
+ <one line to give the program's name and a brief idea of what it does.>
633
+ Copyright (C) <year> <name of author>
634
+
635
+ This program is free software: you can redistribute it and/or modify
636
+ it under the terms of the GNU Affero General Public License as published
637
+ by the Free Software Foundation, either version 3 of the License, or
638
+ (at your option) any later version.
639
+
640
+ This program is distributed in the hope that it will be useful,
641
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+ GNU Affero General Public License for more details.
644
+
645
+ You should have received a copy of the GNU Affero General Public License
646
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+ Also add information on how to contact you by electronic and paper mail.
649
+
650
+ If your software can interact with users remotely through a computer
651
+ network, you should also make sure that it provides a way for users to
652
+ get its source. For example, if your program is a web application, its
653
+ interface could display a "Source" link that leads users to an archive
654
+ of the code. There are many ways you could offer source, and different
655
+ solutions will be better for different programs; see section 13 for the
656
+ specific requirements.
657
+
658
+ You should also get your employer (if you work as a programmer) or school,
659
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+ For more information on this, and how to apply and follow the GNU AGPL, see
661
+ <https://www.gnu.org/licenses/>.
README.md CHANGED
@@ -1,11 +1,9 @@
1
  ---
2
- title: Fsg Pp
3
- emoji: 🌖
4
  colorFrom: purple
5
- colorTo: pink
6
  sdk: docker
7
  pinned: false
8
- license: apache-2.0
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Finally Some Good Profile Pictures
3
+ emoji: 😉
4
  colorFrom: purple
5
+ colorTo: blue
6
  sdk: docker
7
  pinned: false
8
+ license: gpl-3.0
9
+ ---
 
 
ai/autocrop.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import commands.exec_path
2
+ from ultralytics import YOLO
3
+ from PIL import Image, ImageDraw, ImageFont
4
+ import os
5
+ import random
6
+ from pathlib import Path
7
+
8
+ def autoCropImages(image,scale_factor):
9
+ # Load a model
10
+ model = YOLO("./cv_files/AniFaceDet.pt")
11
+
12
+ test_images = []
13
+ test_images.append(image)
14
+
15
+ # Create a directory for saving cropped images
16
+ relative_dir = './Images/cropped'
17
+ cropped_dir = os.path.abspath(relative_dir)
18
+ if not os.path.exists(cropped_dir):
19
+ os.makedirs(cropped_dir)
20
+
21
+ imagesToReturn = []
22
+ # Load the test image
23
+ for img in test_images:
24
+ if img.split(".")[-1] not in ["jpg", "jpeg", "png"]:
25
+ continue
26
+ image_path = Path(image) / img
27
+ image = Image.open(image_path)
28
+
29
+ # Get the size of the image
30
+ image_width, image_height = image.size
31
+
32
+ # Calculate the scaling factor based on the image size for font size
33
+ scaling_factor = max(image_width, image_height) / 200
34
+ # Calculate the final font size by scaling the base font size
35
+ base_font_size = 10
36
+ font_size = int(base_font_size * scaling_factor)
37
+ font = ImageFont.load_default()
38
+
39
+ # Predict the bounding boxes #Defaults conf=0.25, iou=0.7
40
+ pred = model.predict(image, conf=0.65, iou=0.7)
41
+
42
+ # Extract the bounding box coordinates, class labels, and confidence scores
43
+ boxes = pred[0].boxes.xyxy.tolist()
44
+ classes = pred[0].boxes.cls.tolist()
45
+ scores = pred[0].boxes.conf.tolist()
46
+
47
+ # Choose a scale factor for the cropped image
48
+ scale_factor = scale_factor
49
+
50
+ # Loop over all detected faces and draw bounding boxes, crop, and save
51
+ for i in range(len(boxes)):
52
+ box = boxes[i]
53
+ score = scores[i]
54
+
55
+ x1, y1, x2, y2 = box
56
+
57
+ # Calculate the width and height of the bounding box and apply the scale factor
58
+ box_width = x2 - x1
59
+ box_height = y2 - y1
60
+ scaled_width = int(box_width * scale_factor)
61
+ scaled_height = int(box_height * scale_factor)
62
+
63
+ # Calculate the top-left corner coordinates of the cropped region
64
+ cropped_x1 = max(0, int(x1 - (scaled_width - box_width) / 2))
65
+ cropped_y1 = max(0, int(y1 - (scaled_height - box_height) / 2))
66
+
67
+ # Calculate the bottom-right corner coordinates of the cropped region
68
+ cropped_x2 = min(int(x2 + (scaled_width - box_width) / 2), image_width)
69
+ cropped_y2 = min(int(y2 + (scaled_height - box_height) / 2), image_height)
70
+
71
+ # Crop the image based on the detected face
72
+ cropped_image = image.crop((cropped_x1, cropped_y1, cropped_x2, cropped_y2))
73
+
74
+ # Save the cropped image with the original filename and an index
75
+ cropped_image_name = '{}_cropped_{}_scale_{}.jpg'.format(os.path.splitext(os.path.split(img)[-1])[0], i, scale_factor)
76
+ cropped_image_path = os.path.join(cropped_dir, cropped_image_name)
77
+ cropped_image.save(fp=cropped_image_path)
78
+
79
+ # Appending Cropped images in an array to display in gradio for end-user
80
+ imagesToReturn.append(cropped_image_path)
81
+
82
+ print('Cropped image saved:', cropped_image_path)
83
+
84
+ # Draw bounding boxes on the original image
85
+ draw = ImageDraw.Draw(image)
86
+
87
+ return imagesToReturn
88
+
ai/classifying_ai.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import commands.exec_path
2
+ from ultralytics import YOLO
3
+ from PIL import Image, ImageDraw, ImageFont, ImageFile
4
+ import os
5
+ import random
6
+
7
+ model_path = os.path.join(os.getcwd(), 'cv_files/AniClassifier.pt')
8
+ model = YOLO(model_path)
9
+
10
+
11
+ def img_classifier(image, classifer_type=0):
12
+
13
+ test_images = []
14
+ test_images.append(image)
15
+ imagesToReturn = []
16
+
17
+ # Create a directory for saving classified images
18
+ folder_dir = './Images'
19
+ if not os.path.exists(folder_dir):
20
+ os.makedirs(folder_dir)
21
+
22
+ # Classify images with "good" class in the images folder and save them in the image directory
23
+ for img in test_images:
24
+ img_loc = img
25
+ img_class = model(img_loc, verbose=False)
26
+
27
+ # If the first index is higher than the second index, the image is classified as "good"
28
+ if img_class[0].probs.data[0] < img_class[0].probs.data[1]:
29
+
30
+ # Save the image in the classified directory
31
+ if classifer_type:
32
+ image = Image.open(img_loc)
33
+ image.save(folder_dir + img)
34
+
35
+ # Appending Cropped images in an array to display in gradio for end-user
36
+ imagesToReturn.append(folder_dir + img)
37
+ return imagesToReturn
38
+
39
+ # Downloading Thumbnail images so don't save them in the image directory
40
+ else:
41
+ return True
42
+
43
+ else:
44
+ return False
commands/driver_instance.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from selenium import webdriver
2
+ import urllib.request
3
+ import os
4
+ import logging
5
+
6
+ def create_driver(profile=0):
7
+ # Options to make it more human-like
8
+ options = webdriver.ChromeOptions()
9
+ options.add_argument("start-maximized")
10
+ options.add_argument("--disable-blink-features=AutomationControlled")
11
+ options.add_argument("--disable-notifications")
12
+ options.add_argument("--disable-popup-blocking")
13
+ options.add_argument("--disable-extensions")
14
+ options.add_argument("--disable-gpu")
15
+ options.add_argument("--disable-infobars")
16
+ options.add_argument("--disable-dev-shm-usage")
17
+ options.add_argument("--no-sandbox")
18
+
19
+ # May be required to change this later on
20
+ options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36")
21
+
22
+
23
+ user_data_dir = os.path.abspath(os.getcwd())+"/commands/profile"
24
+ if profile:
25
+ options.add_argument(f"user-data-dir={user_data_dir}")
26
+ prefs = {"credentials_enable_service": False,
27
+ "profile.password_manager_enabled": False}
28
+ options.add_experimental_option("prefs", prefs)
29
+ options.add_argument("--headless")
30
+
31
+ # to supress the error messages/logs?
32
+ options.add_argument("--log-level=3")
33
+ options.add_experimental_option("excludeSwitches", ["enable-logging"])
34
+ options.add_experimental_option("excludeSwitches", ["enable-automation"])
35
+
36
+ # Not recommended to change from default value (decides how the page is loaded)
37
+ options.page_load_strategy = 'normal'
38
+
39
+ # Remove logs from console
40
+ selenium_logger = logging.getLogger('selenium')
41
+ selenium_logger.setLevel(logging.ERROR)
42
+
43
+ # Create driver instance (using service is not required)
44
+ driver = webdriver.Chrome(options=options)
45
+ return driver
46
+
47
+ def create_url_headers(tempImg, site=0):
48
+ opener = urllib.request.build_opener()
49
+ if not site:
50
+ site = tempImg
51
+ opener.addheaders = [
52
+ ('Accept', 'application/json, text/javascript, */*; q=0.01'),
53
+ ('X-Requested-With', 'XMLHttpRequest'),
54
+ ('Referer', f'{site}'),
55
+ ('Host', f'https//{tempImg.split("/")[2]}'),
56
+ ('Content-Type', 'application/json; charset=UTF-8'),
57
+ ('Connection', 'keep-alive'),
58
+ ('user-agent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36')
59
+ ]
60
+ return opener
61
+
62
+ def tab_handler(driver, image=0):
63
+ if image:
64
+ tempImg = image.get_attribute("href")
65
+ driver.execute_script("window.open('');")
66
+ driver.switch_to.window(driver.window_handles[1])
67
+ driver.get(f"{tempImg}")
68
+ return driver, tempImg
69
+
70
+ driver.close()
71
+ driver.switch_to.window(driver.window_handles[0])
72
+ return driver
commands/exec_path.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ driver_path = "driver"
4
+ folder_path = "Images"
5
+ driverPath = os.path.join(os.getcwd(), driver_path)
6
+ imagePath = os.path.join(os.getcwd(), folder_path)
7
+
8
+ try:
9
+ if len(os.listdir(driverPath)) > 1:
10
+ raise Exception("Put 1 driver only")
11
+ elif os.listdir(driverPath)[0] != "driver.exe":
12
+ os.rename(driverPath+"/"+"driver.exe")
13
+ except:
14
+ pass
15
+ finally:
16
+ executable_path = os.path.join(driverPath, 'driver.exe')
17
+
18
+
19
+ def imgList(mode=0):
20
+ if mode==0: # Danbooru
21
+ return [image.split(" ")[-1].split(".")[0] for image in os.listdir(imagePath) if image.split(".")[-1] in ["jpg","png","jpeg"]]
22
+ if mode==1: # Pixiv
23
+ return [image.split("_")[0] for image in os.listdir(imagePath) if image.split(".")[-1] in ["jpg","png","jpeg"]]
24
+ if mode==2: # Zerochan
25
+ return os.listdir(imagePath)
commands/universal.py ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from selenium.webdriver.common.by import By
2
+ from selenium.webdriver.common.keys import Keys
3
+ from selenium.webdriver.support.ui import WebDriverWait
4
+ from selenium.webdriver.support import expected_conditions as EC
5
+ import time
6
+
7
+ def searchQuery(user_search, driver, elem, mode=0, score="", isLoggedIn=True):
8
+ if isLoggedIn == False:
9
+ anchors = driver.find_elements(By.XPATH, '//*[@class="sc-93qi7v-2 hbGpVM"]//a')
10
+ for n_iter,anchor in enumerate(anchors):
11
+ if anchor.get_attribute("lang") =="en":
12
+ driver.execute_script("arguments[0].click();", anchor)
13
+
14
+ user_search = user_search.lower()
15
+ try:
16
+ WebDriverWait(driver, timeout=5).until(EC.presence_of_element_located((By.XPATH, elem)))
17
+ except:
18
+ driver.refresh()
19
+ WebDriverWait(driver, timeout=20).until(EC.presence_of_element_located((By.XPATH, elem)))
20
+ search_bar = driver.find_element(By.XPATH, elem)
21
+
22
+ try:
23
+ search_bar.click()
24
+ if not mode:
25
+ time.sleep(1.8)
26
+ driver.execute_script('arguments[0].value=arguments[1]', search_bar, user_search)
27
+ except:
28
+ time.sleep(3)
29
+ driver.execute_script('arguments[0].value=arguments[1]', search_bar, user_search)
30
+
31
+ if not mode:
32
+ specific_Query(driver=driver, search_bar=search_bar, user_search=user_search)
33
+ else:
34
+ search_bar.send_keys(Keys.ARROW_DOWN)
35
+ time.sleep(2)
36
+
37
+ if mode:
38
+ search_bar.send_keys(Keys.ARROW_DOWN)
39
+ time.sleep(1.2)
40
+ search_bar.send_keys(Keys.ENTER)
41
+ time.sleep(0.3)
42
+
43
+ try:
44
+ driver.execute_script("arguments[0].value+=arguments[1]", search_bar, score)
45
+ search_bar.send_keys(Keys.ENTER)
46
+ except:
47
+ pass
48
+
49
+
50
+ def save_Search(driver, mode=0):
51
+ try:
52
+ with open("./commands/url.txt", "r+") as file:
53
+ lines = file.readlines()
54
+
55
+ line_to_modify = mode + 1 # Line number to modify based on mode
56
+ new_line_content = driver.current_url # Content to write to the line
57
+
58
+ if line_to_modify > len(lines):
59
+ lines.extend(['\n'] * (line_to_modify - len(lines)))
60
+ elif lines[line_to_modify - 1].strip() == new_line_content:
61
+ # If the line already has the same content, no action is needed
62
+ return
63
+
64
+ lines[line_to_modify - 1] = new_line_content + '\n'
65
+
66
+ file.seek(0)
67
+ file.writelines(lines)
68
+ file.truncate()
69
+ except:
70
+ line_to_modify = mode + 1 # Line number to modify based on mode
71
+ new_line_content = driver.current_url # Content to write to the line
72
+
73
+ with open("./commands/url.txt", "w") as file:
74
+ lines = ['\n'] * line_to_modify
75
+ lines[line_to_modify - 1] = new_line_content + '\n'
76
+ file.writelines(lines)
77
+
78
+
79
+
80
+ def continue_Search(driver, link, mode=0):
81
+ try:
82
+ with open("./commands/url.txt", "r") as file:
83
+ lines = file.readlines()
84
+
85
+ line_to_read = mode + 1 # Line number to read based on mode
86
+
87
+ if len(lines) >= line_to_read and lines[line_to_read - 1].strip() != '':
88
+ url = lines[line_to_read - 1].strip()
89
+ driver.get(url)
90
+ else:
91
+ driver.get(link)
92
+ except:
93
+ driver.get(link)
94
+
95
+
96
+ def specific_Query(driver, search_bar, user_search):
97
+ user_search = user_search.replace("_"," ").split()
98
+ try:
99
+ for user_word in user_search:
100
+ time.sleep(1.2)
101
+ driver.execute_script('arguments[0].value=arguments[1]', search_bar, user_word)
102
+ time.sleep(0.6)
103
+ search_bar.send_keys(Keys.SPACE)
104
+ time.sleep(2.2)
105
+
106
+ checker = 0
107
+ tag_pos = 0
108
+
109
+ search_bar_queries = driver.find_element(By.XPATH, '//*[@class="sc-1974j38-2 kjWkkt"]').find_elements(By.XPATH, './/*[@class="sc-d98f2c-0"]')
110
+ for n_iter, query in enumerate(search_bar_queries):
111
+ query_text = query.find_element(By.XPATH, './/div//div[2]').text.lower()
112
+
113
+ for text in user_search:
114
+ if query_text.find(text) != -1:
115
+ checker += 1
116
+
117
+ if checker == len(user_search):
118
+ tag_pos = n_iter
119
+ break
120
+ else:
121
+ checker = 0
122
+
123
+ if checker == len(user_search):
124
+ for i in range(tag_pos+1):
125
+ time.sleep(0.5)
126
+ search_bar.send_keys(Keys.ARROW_DOWN)
127
+ break
128
+ except:
129
+ driver.execute_script('arguments[0].value=arguments[1]', search_bar, user_search)
130
+ search_bar.send_keys(Keys.ENTER)
131
+
132
+ def contains_works(driver, elem):
133
+ try:
134
+ WebDriverWait(driver, timeout=9).until(EC.presence_of_element_located((By.XPATH, elem)))
135
+ return True
136
+ except:
137
+ return False
driver/chromedriver ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0e4f5a35fad9c8d70c796a02c92f040a2a8e84a85833e0b0ea92a529fb98f48
3
+ size 13768328
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ selenium
3
+ ultralytics==8.0.228
sites/danbooru.py ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import urllib.request
3
+ import os
4
+ from random import randint
5
+ from selenium.webdriver.common.by import By
6
+ from selenium.webdriver.common.keys import Keys
7
+ from selenium.webdriver.support.ui import WebDriverWait
8
+ from selenium.webdriver.support import expected_conditions as EC
9
+ from commands.driver_instance import create_url_headers, tab_handler
10
+ from commands.exec_path import imgList
11
+ from commands.universal import searchQuery, save_Search, continue_Search, contains_works
12
+ from ai.classifying_ai import img_classifier
13
+
14
+ def getOrderedDanbooruImages(driver, exec_path, user_search, num_pics, num_pages, filters, bl_tags, inc_tags, imageControl):
15
+ global image_locations, bl_tags_list, inc_tags_list, image_names, ai_mode,rating_filters
16
+ image_names = imgList(mode=0)
17
+ image_locations = []
18
+ link = "https://danbooru.donmai.us/"
19
+
20
+ if 0 in imageControl:
21
+ continue_Search(driver, link, mode=1)
22
+ else:
23
+ driver.get(link)
24
+
25
+ # Rating Filter Creation
26
+ rating_filters = ["s","e"]
27
+ rating_filters = ["q","s","e"] if 4 in filters else []
28
+
29
+ # Tag list creation
30
+ score = 1 if 0 in filters else 0
31
+ match_type = 1 if 1 in filters else 0
32
+ r_18 = pg_lenient()
33
+ r_18 = pg_strict() if 3 in filters else r_18
34
+ ai_mode = 1
35
+
36
+ continue_search = 1 if imageControl else 0
37
+
38
+ # Replace spaces to make spaces feasible by the user
39
+ user_search = user_search.replace(" ", "_")
40
+ score = filter_score(score)
41
+
42
+ bl_tags_list = create_filter_tag_list(bl_tags, r_18)
43
+ inc_tags_list = create_tag_list(inc_tags, match_type) if inc_tags else []
44
+
45
+ if 0 not in imageControl:
46
+ searchQuery(user_search, driver, '//*[@name="tags"]', mode=1, score=score)
47
+
48
+ if not contains_works(driver, '//*[@class="posts-container gap-2"]'):
49
+ print("No works found...")
50
+ return []
51
+
52
+ if ai_mode:
53
+ WebDriverWait(driver, timeout=11).until(EC.presence_of_element_located((By.XPATH, '//*[@class="popup-menu-content"]')))
54
+ driver.get(driver.find_element(By.XPATH, '(//*[@class="popup-menu-content"]//li)[6]//a').get_attribute("href"))
55
+
56
+ curr_page = driver.current_url
57
+ while len(image_locations) < num_pics*num_pages:
58
+ pages_to_search(driver, num_pages, num_pics, exec_path)
59
+ if curr_page == driver.current_url and len(image_locations) < num_pics*num_pages:
60
+ print("Reached end of search results")
61
+ break
62
+ curr_page = driver.current_url
63
+ driver.close()
64
+
65
+ return image_locations
66
+
67
+ def filter_score(score):
68
+ if score:
69
+ return " order:score"
70
+ return ""
71
+
72
+ def pages_to_search(driver, num_pages, num_pics, exec_path):
73
+ for i in range(num_pages):
74
+ WebDriverWait(driver, timeout=11).until(EC.presence_of_element_located((By.XPATH, '//*[@class="posts-container gap-2"]')))
75
+ # Selects the picture grids
76
+ images = driver.find_element(
77
+ By.XPATH, '//*[@class="posts-container gap-2"]'
78
+ ).find_elements(By.CLASS_NAME, "post-preview-link")
79
+ grid_search(driver, num_pics, images, exec_path, num_pages)
80
+ save_Search(driver, mode=1)
81
+ if not valid_page(driver) or len(image_locations) >= num_pics*num_pages:
82
+ break
83
+
84
+ def grid_search(driver, num_pics, images, exec_path, num_pages):
85
+ time.sleep(2)
86
+ temp_img_len = len(image_locations)
87
+ for n_iter, image in enumerate(images):
88
+ if len(image_locations) >= num_pics*num_pages or len(image_locations) - temp_img_len >= num_pics:
89
+ break
90
+
91
+ try:
92
+ if image.find_element(By.XPATH, ".//img").get_attribute('src').split("/")[-1].split(".")[0].encode("ascii", "ignore").decode("ascii") in image_names:
93
+ print("\nImage already exists, moving to another image...")
94
+ continue
95
+
96
+ # Has to be checked this way otherwise tags are not visible in headless mode
97
+ img_tags = driver.find_elements(By.CLASS_NAME, "post-preview")[n_iter].get_attribute('data-tags')
98
+ img_rating = driver.find_elements(By.CLASS_NAME, "post-preview")[n_iter].get_attribute('data-rating')
99
+
100
+ if filter_ratings(img_rating,rating_filters) and filter_tags(bl_tags_list, inc_tags_list, img_tags):
101
+
102
+
103
+ if ai_mode:
104
+ checker = 0
105
+ image_loc = download_image(exec_path=exec_path, driver=driver, image=image)
106
+ if img_classifier(image_loc):
107
+ print("AI Mode: I approve this image")
108
+ else:
109
+ print("AI Mode: Skipping this image")
110
+ checker = 1
111
+ os.remove(image_loc)
112
+ if checker:
113
+ continue
114
+
115
+ driver, tempImg = tab_handler(driver=driver,image=image)
116
+ WebDriverWait(driver, timeout=15).until(EC.presence_of_element_located((By.XPATH, '//*[@id="post-option-download"]/a')))
117
+ download_image(exec_path=exec_path, driver=driver)
118
+ driver = tab_handler(driver=driver)
119
+
120
+ else:
121
+ print("\nFilters did not match/Not an image, moving to another image...")
122
+
123
+ except:
124
+ print("\nI ran into an error, closing the tab and moving on...")
125
+ if driver.window_handles[-1] != driver.window_handles[0]:
126
+ driver = tab_handler(driver=driver)
127
+ time.sleep(randint(0,2) + randint(0,9)/10)
128
+
129
+ def filter_ratings(img_rating,rating_filters):
130
+ if img_rating not in rating_filters:
131
+ return True
132
+ return False
133
+
134
+ def filter_tags(bl_tags_list, inc_tags_list, img_tags):
135
+ # Hashmap of picture's tags for O(1) time searching
136
+ img_hash = {}
137
+ for img_tag in img_tags.split(" "):
138
+ img_hash[img_tag] = 1
139
+
140
+ # Included tags (exact match or not exact)
141
+ if inc_tags_list and inc_tags_list[-1] == 1:
142
+ inc_tags_list.pop()
143
+ for tag in inc_tags_list:
144
+ if not img_hash.get(tag, 0):
145
+ return False
146
+ elif inc_tags_list:
147
+ cond = False
148
+ for tag in inc_tags_list:
149
+ if img_hash.get(tag, 0):
150
+ cond = True
151
+ break
152
+ if not cond:
153
+ return False
154
+
155
+ # Note that bl_tags_list is never empty since it filters videos
156
+ for tag in bl_tags_list:
157
+ if img_hash.get(tag,0):
158
+ return False
159
+ return True
160
+
161
+ def create_tag_list(inc_tags, match_type):
162
+ temp_tags = [tag.lstrip().replace(" ","_") for tag in inc_tags.split(",")]
163
+ if match_type:
164
+ temp_tags.append(1)
165
+ return temp_tags
166
+
167
+ def create_filter_tag_list(bl_tags, r_18):
168
+ temp_tags = ["animated", "video", "sound"]
169
+ if bl_tags:
170
+ temp_tags += [tag.lstrip().replace(" ","_") for tag in bl_tags.split(",")]
171
+ if r_18:
172
+ temp_tags += r_18
173
+ return temp_tags
174
+
175
+ # Find the next page and ensure it isn't the last page
176
+ def valid_page(driver):
177
+ cur_url = driver.current_url
178
+ driver.find_element(By.CLASS_NAME, "paginator-next").click()
179
+ if cur_url == driver.current_url:
180
+ return 0
181
+ return 1
182
+
183
+ def pg_lenient():
184
+ return ["sex","penis","vaginal","completely_nude","nude","exposed_boobs","ahegao","cum","no_panties","no_bra",
185
+ "nipple_piercing", "anal_fluid","uncensored", "see-through", "pussy", "cunnilingus", "oral", "ass_focus",
186
+ "anal", "sex_from_behind", "cum_on_clothes", "cum_on_face", "nipple","nipples", "missionary"
187
+ "fellatio", "rape", "breasts_out","cum_in_pussy", "condom", "dildo", "sex_toy", "cum_in_mouth", "heavy_breathing", "cum_on_tongue"
188
+ "panties", "panty_pull", "nude_cover", "underwear_only","grabbing_own_breast","ass_grab","censored","areola_slip","areolae","torn_pantyhose","micro_bikini","steaming_body"]
189
+
190
+ def pg_strict():
191
+ return pg_lenient() + ["piercings", "cleavage","boobs","thongs","fellatio_gesture", "mosaic_censoring", "ass", "mosaic_censoring",
192
+ "covered_nipples", "thigh_focus", "thighs", "bikini", "swimsuit", "grabbing_another's_breast", "huge_breasts",
193
+ "foot_focus", "licking_foot", "foot_worship", "shirt_lift","clothes_lift", "underwear", "panties_under_pantyhose"]
194
+
195
+ def download_image(exec_path, driver, image=0):
196
+ if not image:
197
+ tempDL = driver.find_element(By.XPATH, '//*[@id="post-option-download"]/a')
198
+ tempDLAttr = tempDL.get_attribute("href")
199
+ tempDLName = tempDL.get_attribute("download").encode('ascii', 'ignore').decode('ascii')
200
+ else:
201
+ tempDLAttr = image.find_element(By.XPATH, ".//img").get_attribute('src')
202
+ tempDLName = tempDLAttr.split("/")[-1].encode("ascii", "ignore").decode("ascii")
203
+ print(f"\n{tempDLAttr.split('?')[0]}")
204
+
205
+ img_loc = f"./{exec_path.folder_path}/{tempDLName}"
206
+ urllib.request.urlretrieve(
207
+ tempDLAttr, f"./{exec_path.folder_path}/{tempDLName}"
208
+ )
209
+ if not image:
210
+ image_locations.append(f"./{exec_path.folder_path}/{tempDLName}")
211
+ image_names.append(f"{tempDLName.split('.')[0]}")
212
+ return img_loc
sites/pixiv.py ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ sys.path.append("..")
3
+
4
+ import time
5
+ import urllib.request
6
+ import os
7
+ import re
8
+ from selenium.webdriver.common.action_chains import ActionChains
9
+ from selenium.webdriver.common.by import By
10
+ from selenium.webdriver.common.keys import Keys
11
+ from selenium.webdriver.support.ui import WebDriverWait
12
+ from selenium.webdriver.support import expected_conditions as EC
13
+ from selenium.common.exceptions import TimeoutException
14
+ from datetime import date, datetime
15
+ from random import randint
16
+ from commands.driver_instance import create_url_headers, tab_handler
17
+ from commands.exec_path import imgList
18
+ from commands.universal import searchQuery, save_Search, continue_Search, contains_works
19
+ from ai.classifying_ai import img_classifier
20
+
21
+
22
+ def getOrderedPixivImages(driver,exec_path,user_search,num_pics,num_pages,searchTypes,viewRestriction,imageControl,
23
+ n_likes,n_bookmarks,n_views, start_date=0,end_date=0, user_name=0, pass_word=0):
24
+ global image_locations, image_names, ultimatium, ai_mode, prev_search
25
+ image_names = imgList(mode=1)
26
+ image_locations = []
27
+ prev_search = 0
28
+ link = "https://www.pixiv.net/tags/illustration"
29
+ success_login = False
30
+
31
+ filters = {
32
+ "likes": 0 if not n_likes else n_likes,
33
+ "bookmarks": 0 if not n_bookmarks else n_bookmarks,
34
+ "viewcount": 0 if not n_views else n_views,
35
+ }
36
+ searchLimit = {"pagecount": num_pages, "imagecount": num_pics}
37
+
38
+ start_date = start_date if date_handler(start_date) else ""
39
+ end_date = date.today() if not date_handler(end_date) else end_date
40
+
41
+ if 1 in imageControl:
42
+ continue_Search(driver, link, mode=0)
43
+ else:
44
+ driver.get(link)
45
+
46
+ # Will use those when not logged in
47
+ bar_search = '//input[@placeholder="Search works"]'
48
+ li_search = "//h3[contains(text(), 'Works') or contains(text(), 'Illustrations and Manga') or contains(text(), 'Illustrations')]/ancestor::section[1]/div[2]//li"
49
+ premium_search = "//h3[contains(text(), 'Popular works')]/ancestor::section[1]/div[2]//li"
50
+ search_param = {
51
+ "bar_search": bar_search,
52
+ "li_search": li_search,
53
+ "premium_search": premium_search,
54
+ }
55
+
56
+ # Check if logged in otherwise log in with credentials
57
+ try:
58
+ # Explicit wait to check for favorite button (only appears for logged in users)
59
+ WebDriverWait(driver, timeout=6).until(
60
+ EC.presence_of_element_located((By.XPATH, "//button[contains(text(), 'Add to your favorites')]")))
61
+
62
+ if driver.find_elements(By.XPATH, "//button[contains(text(), 'Add to your favorites')]"):
63
+ success_login = True
64
+
65
+ if not success_login:
66
+ print("Failed! You are not logged in...")
67
+
68
+ except:
69
+ print("Failed! You are not logged in...")
70
+ pass
71
+
72
+ if 1 not in imageControl:
73
+ searchQuery(user_search, driver, search_param["bar_search"], isLoggedIn=success_login)
74
+ time.sleep(2)
75
+
76
+ if start_date and not success_login:
77
+ driver.get(driver.current_url + f"?scd={start_date}&ecd={end_date}")
78
+ time.sleep(2)
79
+ elif start_date and success_login:
80
+ cur_url = driver.current_url.split("?")
81
+ driver.get(cur_url[0] + f"?scd={start_date}&ecd={end_date}&" + cur_url[1])
82
+ time.sleep(2)
83
+
84
+ premiumSearch = 1 if 0 in searchTypes else 0
85
+ freemiumSearch = 1 if 1 in searchTypes else 0
86
+ pg_friendly = 1 if 0 in viewRestriction else 0
87
+ r_18 = 1 if 1 in viewRestriction else 0
88
+ ultimatium = 1 if 0 in imageControl else 0
89
+ order_by_oldest = 1 if 2 in imageControl else 0
90
+ ai_mode = 1
91
+
92
+ if not contains_works(driver, search_param["li_search"]):
93
+ print("No works found...")
94
+ return []
95
+
96
+ if premiumSearch == 1:
97
+ search_image(driver, exec_path, filters, search_param)
98
+
99
+ # Switch to english
100
+ try:
101
+ english_span = driver.find_element(By.XPATH, "//span[contains(text(), 'English')]")
102
+ driver.execute_script("arguments[0].click();", english_span)
103
+ except:
104
+ pass
105
+
106
+ # Apply filters if logged in
107
+ if success_login:
108
+ try:
109
+ driver.find_element(By.XPATH, "/html/body/div[1]/div[2]/div/div[3]/div/div[5]/nav/a[2]").click()
110
+ print("Illustrations only")
111
+ time.sleep(1)
112
+
113
+ mode = ""
114
+ order = ""
115
+
116
+ if pg_friendly == 1 and r_18 == 1:
117
+ print("PG Friendly and r-18")
118
+ elif pg_friendly == 1:
119
+ mode = "mode=safe&"
120
+ print("PG Friendly")
121
+ elif r_18 == 1:
122
+ mode = "mode=r18&"
123
+ print("r-18")
124
+ if order_by_oldest == 1:
125
+ order = "order=date&"
126
+ print("Order by oldest")
127
+
128
+ cur_url = driver.current_url.split("?")
129
+ driver.get(cur_url[0] + f"?{order}{mode}" + cur_url[1])
130
+ except:
131
+ pass
132
+
133
+ # Click show all results
134
+ try:
135
+ time.sleep(1)
136
+ show_all_div = driver.find_element(By.XPATH, "//div[contains(text(), 'Show all')]")
137
+ if show_all_div:
138
+ driver.find_element(By.XPATH, '//*[@class="sc-d98f2c-0 sc-s46o24-1 dAXqaU"]').click()
139
+ except:
140
+ pass
141
+
142
+ prev_search = len(image_locations)
143
+ curr_page = driver.current_url
144
+
145
+ if freemiumSearch:
146
+ while len(image_locations) < num_pics*num_pages:
147
+ search_image(driver,exec_path,filters,search_param=search_param,searchLimit=searchLimit)
148
+ if not valid_page(driver) and len(image_locations) < num_pics*num_pages:
149
+ print("Reached end of search results")
150
+ break
151
+ driver.quit()
152
+
153
+ return image_locations
154
+
155
+
156
+ def search_image(driver,exec_path,filters,search_param,searchLimit={"pagecount": 1, "imagecount": 99}):
157
+ # Searches using premium or freemium
158
+ search_type = awaitPageLoad(driver=driver,searchLimit=searchLimit,search_param=search_param)
159
+ if search_type == -1:
160
+ return
161
+
162
+ # The main image searcher
163
+ for page in range(searchLimit["pagecount"]):
164
+
165
+ temp_img_len = len(image_locations)
166
+ WebDriverWait(driver, timeout=9).until(
167
+ EC.presence_of_element_located(
168
+ (By.XPATH, search_param["li_search"] + "//a")))
169
+ images = search_image_type(search_type, driver, search_param=search_param)
170
+
171
+ for image in images:
172
+ time.sleep(2)
173
+ if len(image_locations) - prev_search >= searchLimit["imagecount"]*searchLimit["pagecount"] or len(image_locations) - temp_img_len >= searchLimit["imagecount"]:
174
+ break
175
+ image = image.find_element(By.XPATH, "." + "/" + "/a")
176
+ imageLink = image.find_elements(By.XPATH, ".//img")
177
+
178
+ if image.get_attribute("href").rsplit("/", 1)[-1] not in image_names:
179
+ if ai_mode == 1 and process_ai_mode(imageLink, image, driver, exec_path):
180
+ continue
181
+
182
+ try:
183
+ if sum(filters.values()) == 0 and len(imageLink): # Dl the image directly from the grid
184
+ thumbnailDownloader(imageLink=imageLink, image=image, driver=driver, exec_path=exec_path)
185
+
186
+ else: # Dl the image from the image page (opens a new tab)
187
+ driver, tempImg = tab_handler(driver=driver, image=image)
188
+ WebDriverWait(driver, timeout=11).until(EC.presence_of_element_located((By.XPATH, "//div[@role='presentation']")))
189
+ tempDL = driver.find_element(By.XPATH, "//div[@role='presentation']//img")
190
+
191
+ imagePopularity = parseImageData(filters=filters,
192
+ Data=driver.find_elements(By.TAG_NAME, "dd"))
193
+ time.sleep(1)
194
+
195
+ if filterOptions(filters, imagePopularity=imagePopularity): # Check if image filters are satisfied
196
+ tempDLLink = tempDL.get_attribute("src")
197
+
198
+ # Dl the original rez image
199
+ if ultimatium:
200
+ tempDLLink = tempDLLink.replace("img-master", "img-original"
201
+ ).replace("_master1200", "")
202
+
203
+ download_image(imageLink=tempDLLink, exec_path=exec_path, driver=driver)
204
+ else:
205
+ print("\nImage filters not satisfied...")
206
+ driver = tab_handler(driver=driver)
207
+ time.sleep(0.3)
208
+
209
+ # In case of stale element or any other errors
210
+ except:
211
+ if driver.window_handles[-1] != driver.window_handles[0]:
212
+ print("\nI ran into an error, moving on...")
213
+ driver = tab_handler(driver=driver)
214
+ time.sleep(randint(1, 3) + randint(0, 9) / 10)
215
+ continue
216
+
217
+ else:
218
+ print("\nImage already exists, moving to another image...")
219
+ save_Search(driver, mode=0)
220
+ if not valid_page(driver):
221
+ break
222
+
223
+
224
+ ######## FUNCTIONS PRONE TO CHANGE ########
225
+ def login_handler(driver, exec_path, user_name, pass_word):
226
+ time.sleep(5)
227
+ login_btn = driver.find_elements(By.XPATH, "//*[@class='sc-oh3a2p-4 gHKmNu']//a")[1]
228
+ login_btn.click()
229
+
230
+ WebDriverWait(driver, timeout=11).until(
231
+ EC.presence_of_element_located((By.XPATH, "//*[@class='sc-2o1uwj-0 elngKN']"))
232
+ )
233
+ user_btn = driver.find_element(
234
+ By.XPATH, "//*[@class='sc-2o1uwj-0 elngKN']"
235
+ ).find_elements(By.TAG_NAME, "fieldset")
236
+ user_btn[0]
237
+
238
+ actions = ActionChains(driver)
239
+ actions.click(user_btn[0]).send_keys(user_name).perform()
240
+ time.sleep(0.5)
241
+ actions.click(user_btn[1]).send_keys(pass_word).perform()
242
+
243
+ # Log in button
244
+ driver.find_element(By.XPATH,"//button[contains(text(), 'Log In')]").click()
245
+
246
+ return True
247
+
248
+
249
+ def download_image(imageLink, exec_path, driver, mode=1):
250
+ tempDLName = imageLink.rsplit("/", 1)[-1]
251
+ img_loc = f"./{exec_path.folder_path}/{tempDLName}"
252
+ if not ultimatium or not mode:
253
+ installUrlOpeners(driver=driver,mode=0)
254
+ else:
255
+ installUrlOpeners(imageLink)
256
+ try:
257
+ requestUrlretrieve(imageLink=imageLink, img_loc=img_loc)
258
+ except:
259
+ imageLink = imageLink.rsplit(".",1)[0]+".png"
260
+ requestUrlretrieve(imageLink, img_loc=img_loc)
261
+
262
+ print(f"\n{imageLink}")
263
+ if mode:
264
+ image_locations.append(f"./{exec_path.folder_path}/{tempDLName}")
265
+ image_names.append(f"{tempDLName.split('.')[0]}")
266
+ else:
267
+ return img_loc
268
+
269
+
270
+ def thumbnailDownloader(imageLink, image, driver, exec_path, mode=1):
271
+ imageLink = image_type(imageLink=imageLink, mode=mode)
272
+
273
+ action = ActionChains(driver=driver)
274
+ action.move_to_element(image.find_element(By.XPATH, ".//img")).perform()
275
+
276
+ return download_image(imageLink=imageLink, exec_path=exec_path, driver=driver, mode=mode)
277
+
278
+
279
+ ######## URLLIB LIBRARY ########
280
+ def installUrlOpeners(driver,mode=1): # Mode 0 means its a thumbnail
281
+ if ultimatium and mode:
282
+ urllib.request.install_opener(create_url_headers(driver))
283
+ else:
284
+ urllib.request.install_opener(create_url_headers(driver.current_url))
285
+
286
+ def requestUrlretrieve(imageLink, img_loc): # Download the image
287
+ urllib.request.urlretrieve(imageLink, img_loc)
288
+
289
+
290
+ ######## HELPER FUNCTIONS (UNLIKELY TO CHANGE) ########
291
+ # Handles the search type (premium or freemium)
292
+ def search_image_type(search_type, driver, search_param):
293
+ if search_type == 0:
294
+ return driver.find_elements(By.XPATH, search_param["premium_search"])
295
+ elif search_type == 1:
296
+ return driver.find_elements(By.XPATH, search_param["li_search"])
297
+
298
+
299
+ # Handles the image type (if mode then it is not a thumbnail, so switch it to view res else Max res)
300
+ def image_type(imageLink, mode=0):
301
+ imageLink = imageLink[0].get_attribute("src")
302
+ if mode: # View res
303
+ imageLink = re.sub(r"c/.*?/.*?/", "img-master/", imageLink)
304
+ imageLink = imageLink.replace("square", "master").replace("custom", "master")
305
+
306
+ if ultimatium: # Max res
307
+ imageLink = imageLink.replace("img-master", "img-original").replace("_master1200", "")
308
+ return imageLink
309
+
310
+
311
+ # Handles finding the popular or freemium section
312
+ def awaitPageLoad(driver, searchLimit, search_param, search_type=0):
313
+ # Waits on the page to load (for popular or freemium)
314
+ if searchLimit["imagecount"] == 99:
315
+ try:
316
+ WebDriverWait(driver, timeout=12).until(
317
+ EC.presence_of_element_located(
318
+ (By.XPATH, search_param["premium_search"])
319
+ )
320
+ )
321
+ print("Premium section found, searching for images...")
322
+ except:
323
+ print("No popular section")
324
+ search_type = -1
325
+ return search_type
326
+ else:
327
+ try:
328
+ WebDriverWait(driver, timeout=12).until(
329
+ EC.presence_of_element_located((By.XPATH, search_param["li_search"]))
330
+ )
331
+ print("\nFreemium section found, searching for images...")
332
+ except:
333
+ driver.refresh()
334
+ time.sleep(12)
335
+ if not driver.find_elements(By.XPATH, search_param["li_search"]):
336
+ return
337
+ search_type = 1
338
+ return search_type
339
+
340
+
341
+ def filterOptions(filters, imagePopularity):
342
+ for key in filters.keys():
343
+ if filters[key] > imagePopularity[key]:
344
+ return False
345
+ return True
346
+
347
+
348
+ def parseImageData(Data, filters):
349
+ parsedData = {}
350
+ for iter, key in enumerate(filters.keys()):
351
+ parsedData[key] = int(Data[iter].text.replace(",", ""))
352
+ return parsedData
353
+
354
+
355
+ def valid_page(driver):
356
+ cur_url = driver.current_url
357
+ try:
358
+ next_page = (
359
+ driver.find_element(By.XPATH, '//*[@class="sc-xhhh7v-0 kYtoqc"]')
360
+ .find_elements(By.XPATH, ".//a")[-1]
361
+ .get_attribute("href")
362
+ )
363
+ if cur_url == next_page:
364
+ return 0
365
+ if next_page:
366
+ driver.get(next_page)
367
+ return 1
368
+ except:
369
+ return 0
370
+
371
+
372
+ def date_handler(sel_date):
373
+ temp = sel_date.split("-")
374
+ try:
375
+ datetime(int(temp[0]), int(temp[1]), int(temp[2]))
376
+ except ValueError:
377
+ return 0
378
+ return 1
379
+
380
+
381
+ def process_ai_mode(imageLink, image, driver, exec_path):
382
+ try:
383
+ # Dl the image thumbnail from the grid
384
+ img_loc = thumbnailDownloader(imageLink=imageLink, image=image, driver=driver, exec_path=exec_path, mode=0)
385
+
386
+ if img_classifier(img_loc):
387
+ print("AI Mode: I approve this image")
388
+ return False
389
+ else:
390
+ print("AI Mode: Skipping this image")
391
+ return True
392
+ os.remove(img_loc)
393
+ except:
394
+ return True
sites/yandex.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import urllib.request
3
+ import os
4
+ import re
5
+ from random import randint
6
+ from selenium.webdriver.common.by import By
7
+ from selenium.webdriver.common.keys import Keys
8
+ from selenium.webdriver.support.ui import WebDriverWait
9
+ from selenium.webdriver.support import expected_conditions as EC
10
+ from commands.driver_instance import create_url_headers, tab_handler
11
+ from commands.exec_path import imgList
12
+ from commands.universal import searchQuery, save_Search, continue_Search, contains_works
13
+ from ai.classifying_ai import img_classifier
14
+
15
+
16
+ def getOrderedYandexImages(
17
+ driver, exec_path, user_search, num_pics, filters, imageOrientation):
18
+ global image_locations, image_names, ai_mode
19
+ image_names = imgList(mode=2)
20
+ ai_mode = True
21
+ recents = True if 1 in filters else False
22
+
23
+ image_locations = []
24
+ link = "https://yandex.com/images/search?isize=large&"
25
+ link = link + "text=" + user_search.replace(" ", "+").replace("_", "+")
26
+ if imageOrientation:
27
+ orientations = ["horizontal", "vertical", "square"]
28
+ link += f"&iorient={orientations[imageOrientation]}"
29
+ driver.get(link)
30
+
31
+ WebDriverWait(driver, timeout=11).until(
32
+ EC.presence_of_element_located((By.XPATH, '//*[@class="SerpList"]'))
33
+ )
34
+
35
+ driver.find_element(
36
+ By.XPATH,
37
+ "//*[@class='SimpleImage SimpleImage_showPlaceholderIcon SerpItem-Thumb']//a",
38
+ ).click()
39
+
40
+ grid_search(driver, num_pics, exec_path, user_search)
41
+
42
+ time.sleep(20)
43
+ driver.close()
44
+
45
+ return image_locations
46
+
47
+
48
+ def grid_search(driver, num_pics, exec_path, user_search):
49
+ WebDriverWait(driver, timeout=11).until(
50
+ EC.presence_of_element_located(
51
+ (By.XPATH, "//*[contains(@class, 'MMGallery-Item')]")
52
+ )
53
+ )
54
+ images = driver.find_elements(By.XPATH, "//*[@class='MMGallery-Container']/*")
55
+
56
+ for image in images:
57
+ time.sleep(2)
58
+ # Navigate the webpage and filter the image link
59
+ try:
60
+ if len(image_locations) >= num_pics:
61
+ break
62
+
63
+ driver.execute_script("arguments[0].click();", image)
64
+ time.sleep(0.5)
65
+ imageLink = driver.find_element(
66
+ By.XPATH,
67
+ '//*[@class="OpenImageButton OpenImageButton_text OpenImageButton_sizes MMViewerButtons-OpenImageSizes"]//a',
68
+ ).get_attribute("href")
69
+
70
+ if (imageLink.rsplit("/",1)[-1].encode("ascii", "ignore")
71
+ .decode("ascii")) in image_names:
72
+ print("Image already exists, moving to another image...\n")
73
+ continue
74
+ except:
75
+ print("I ran into an error finding the image, closing the tab and moving on...\n")
76
+ time.sleep(randint(0, 1) + randint(0, 9) / 10)
77
+ continue
78
+
79
+ # Ai mode check
80
+ try:
81
+ if ai_mode:
82
+ checker = ai_dl(image, exec_path, driver, user_search)
83
+ if checker:
84
+ continue
85
+ except Exception as e: # TODO: Implement proper exception handling in case of http error 404
86
+ time.sleep(randint(0, 1) + randint(0, 9) / 10)
87
+ checker = ai_dl(image, exec_path, driver, user_search, site="https://yandex.com/")
88
+ except:
89
+ time.sleep(randint(0, 1) + randint(0, 9) / 10)
90
+ print("AI mode failed to check the image, skipping...\n")
91
+ continue
92
+
93
+ # Download the image
94
+ try:
95
+ download_image(
96
+ exec_path=exec_path,
97
+ driver=driver,
98
+ image=imageLink,
99
+ user_search=user_search,
100
+ )
101
+ except: # TODO: Use the same exception handling as above to try and redownload the image
102
+ print("I ran into an error downloading, closing the tab and moving on...\n")
103
+ time.sleep(randint(0, 1) + randint(0, 9) / 10)
104
+
105
+
106
+ def download_image(exec_path, driver, image, user_search, mode=1, site=0):
107
+ tempDLAttr = image
108
+ matching = re.search(r"([^/]+\.(?:jpg|jpeg|png|webp))", image.rsplit("/", 1)[-1])
109
+
110
+ if not matching:
111
+ tempDLAttr += ".png"
112
+ if tempDLAttr.startswith('//'):
113
+ tempDLAttr = 'https:' + tempDLAttr
114
+
115
+ tempDLName = (
116
+ re.search(r"([^/]+\.(?:jpg|jpeg|png|webp))", tempDLAttr.rsplit("/", 1)[-1])
117
+ .group(1)
118
+ .encode("ascii", "ignore")
119
+ .decode("ascii"))
120
+
121
+ if not mode:
122
+ tempDLName = re.sub(r'[\\/*?:"<>|]', "", tempDLName)
123
+ img_loc = f"./{exec_path.folder_path}/{tempDLName}"
124
+
125
+ # User other site headers (to be implemented properly)
126
+ if site:
127
+ urllib.request.install_opener(create_url_headers(tempDLAttr, site=site))
128
+ urllib.request.urlretrieve(tempDLAttr, img_loc)
129
+
130
+ urllib.request.install_opener(create_url_headers(tempDLAttr))
131
+ urllib.request.urlretrieve(tempDLAttr, img_loc)
132
+
133
+ if mode:
134
+ print(f"{tempDLAttr}\n")
135
+ image_locations.append(img_loc)
136
+ image_names.append(f"{tempDLName.split('.')[0]}")
137
+ return img_loc
138
+
139
+
140
+ def ai_dl(image, exec_path, driver, user_search, site=""):
141
+ checker = 0
142
+ image_thumbnail = image.find_element(
143
+ By.XPATH, './/*[@class="MMThumbImage-Image"]'
144
+ ).get_attribute("style")
145
+
146
+ # Filter url from the style attribute
147
+ image_thumbnail = re.findall(r'url\("(.+?)"\)', image_thumbnail)[0]
148
+
149
+ # Download the image thumbnail
150
+ image_loc = download_image(
151
+ exec_path=exec_path,
152
+ driver=driver,
153
+ image=image_thumbnail,
154
+ user_search=user_search,
155
+ mode=0,
156
+ site=site
157
+ )
158
+
159
+ # Check if the image is good or not and delete the image
160
+ if img_classifier(image_loc):
161
+ print("AI Mode: I approve this image")
162
+ else:
163
+ print("AI Mode: Skipping this image\n")
164
+ checker = 1
165
+ os.remove(image_loc)
166
+ return checker
sites/zerochan.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import urllib.request
3
+ import os
4
+ from random import randint
5
+ from selenium.webdriver.common.by import By
6
+ from selenium.webdriver.common.keys import Keys
7
+ from selenium.webdriver.support.ui import WebDriverWait
8
+ from selenium.webdriver.support import expected_conditions as EC
9
+ from selenium.common.exceptions import TimeoutException
10
+ from commands.driver_instance import create_url_headers, tab_handler
11
+ from commands.exec_path import imgList
12
+ from commands.universal import contains_works, save_Search, continue_Search
13
+ from ai.classifying_ai import img_classifier
14
+
15
+ def getOrderedZerochanImages(driver, exec_path, user_search, num_pics, num_pages, n_likes, filters, imageControl):
16
+ global image_locations, image_names, ultimatium, ai_mode
17
+ image_names = imgList(mode=1)
18
+ image_locations = []
19
+
20
+ ai_mode = 1
21
+ filters={'likes': 0 if not n_likes else n_likes}
22
+ searchLimit={'pagecount': num_pages,'imagecount':num_pics}
23
+ user_search = user_search.replace(" ","+").capitalize()
24
+ link = "https://www.zerochan.net/" + user_search
25
+
26
+ if not imageControl:
27
+ driver.get(link)
28
+ if imageControl:
29
+ continue_Search(driver, link, mode=2)
30
+
31
+ if driver.current_url == "https://www.zerochan.net/":
32
+ print("You continued for the first time, but there was no previous search to continue from!")
33
+ driver.get(driver.current_url + 'angry')
34
+
35
+
36
+ is_valid_search(driver)
37
+ if not contains_works(driver, '//*[@id="thumbs2"]'):
38
+ print("No works found...")
39
+ return []
40
+
41
+ curr_page = driver.current_url
42
+ while len(image_locations) < num_pics*num_pages:
43
+ search_image(driver,exec_path,filters,searchLimit=searchLimit)
44
+ if curr_page == driver.current_url and len(image_locations) < num_pics*num_pages or image_locations[-1]==-1:
45
+ image_locations.pop()
46
+ print("Reached end of search results")
47
+ break
48
+ curr_page = driver.current_url
49
+ driver.quit()
50
+
51
+ return image_locations
52
+
53
+ def search_image(driver, exec_path, filters, searchLimit):
54
+ filter_link = "https://www.zerochan.net/register"
55
+
56
+ # The main image searcher
57
+ for page in range(searchLimit["pagecount"]):
58
+ temp_img_len = len(image_locations)
59
+ save_Search(driver=driver, mode=2)
60
+ WebDriverWait(driver, timeout=11).until(EC.presence_of_element_located((By.XPATH, "//*[@id='thumbs2']")))
61
+ images = driver.find_elements(By.XPATH, "//*[@id='thumbs2']//li")
62
+ if image_locations and image_locations[-1] == -1:
63
+ break
64
+
65
+ for curr_iter,image in enumerate(images):
66
+ tempImg = image.find_element(By.XPATH,".//a").get_attribute("href")
67
+ if len(image_locations) >= searchLimit['imagecount']*searchLimit['pagecount'] or len(image_locations) - temp_img_len >= searchLimit['imagecount']:
68
+ break
69
+ try:
70
+ tempDLLink = image.find_elements(By.XPATH, ".//p//a")[0].get_attribute("href")
71
+ if tempDLLink.split(".")[-1] not in ["jpg","png","jpeg"]:
72
+ tempDLLink = image.find_elements(By.XPATH, ".//p//a")[1].get_attribute("href")
73
+ tempDLAttr = tempDLLink.split("/")[-1]
74
+ counts = tempDLAttr.count(".")-1
75
+ tempDLAttr = tempDLAttr.replace(".", " ", counts).encode("ascii", "ignore").decode("ascii")
76
+
77
+ if tempImg == filter_link or tempDLAttr in image_names:
78
+ print("\nImage already exists, moving to another image...")
79
+ continue
80
+
81
+ rand_time = randint(0,1) + randint(0,9)/10
82
+ time.sleep(rand_time)
83
+ if int(image.find_element(By.XPATH, './/*[@class="fav"]').get_property("text"))>filters["likes"]:
84
+ urllib.request.install_opener(create_url_headers(tempImg=tempImg))
85
+ urllib.request.urlretrieve(
86
+ tempDLLink, f"./{exec_path.folder_path}/{tempDLAttr}"
87
+ )
88
+ image_locations.append(f"./{exec_path.folder_path}/{tempDLAttr}")
89
+ image_names.append(f"{tempDLAttr}")
90
+ print(f"\n{tempDLLink}")
91
+ if ai_mode:
92
+ if img_classifier(image_locations[-1]):
93
+ print("AI Mode: I approve this image")
94
+ else:
95
+ os.remove(image_locations[-1])
96
+ image_locations.pop()
97
+ image_names.pop()
98
+ print("AI Mode: Skipping this image")
99
+
100
+ else:
101
+ image_locations.append(-1)
102
+
103
+ # In case of stale element or any other errors
104
+ except:
105
+ if driver.window_handles[-1] != driver.window_handles[0]:
106
+ print("I ran into an error, closing the tab and moving on...")
107
+ driver = tab_handler(driver=driver)
108
+ time.sleep(randint(1,3) + randint(0,9)/10)
109
+ continue
110
+
111
+
112
+ if not valid_page(driver):
113
+ break
114
+
115
+ def valid_page(driver):
116
+ try:
117
+ driver.get(driver.find_elements(By.XPATH, "//*[@class='pagination']//a")[-1].get_attribute("href"))
118
+ return True
119
+ except:
120
+ return False
121
+
122
+ def is_valid_search(driver):
123
+ try:
124
+ titles = driver.find_element(By.XPATH, "//*[@id='children']//a").get_attribute("href")
125
+ if titles:
126
+ driver.get(titles)
127
+ except:
128
+ pass
style.css ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import url("https://fonts.googleapis.com/css2?family=Lexend&display=swap");
2
+
3
+ :root {
4
+ --font: "Lexend", sans-serif !important;
5
+ --dark-purple: #242038 !important;
6
+ --button-secondary-background-fill: #c5b0fc !important;
7
+ --button-secondary-background-fill-hover: #a288e3 !important;
8
+ --button-secondary-border-color: var(--dark-purple) !important;
9
+ --border-color-primary: #9067c6 !important;
10
+
11
+ --slider-color: #c5b0fc !important;
12
+ --block-title-text-color: #fafaff !important;
13
+ --input-background-fill: var(--dark-purple) !important;
14
+ --neutral-800: #fafaff !important;
15
+
16
+ --checkbox-label-background-fill: var(--dark-purple) !important;
17
+ --checkbox-label-background-fill-hover: var(--dark-purple) !important;
18
+ --checkbox-background-color: #a288e3 !important;
19
+ --checkbox-border-color: #a288e3 !important;
20
+ --checkbox-background-color-hover: #c5b0fc !important;
21
+ --checkbox-background-color-selected: var(--dark-purple) !important;
22
+ --checkbox-border-color-focus: var(--dark-purple) !important;
23
+ --checkbox-border-color-selected: #c5b0fc !important;
24
+ --shadow-spread: 3px !important;
25
+ --shadow-inset: rgba(0, 0, 0, 0.05) 0px 2px 4px 0px inset !important;
26
+ --shadow-drop: 0px !important;
27
+ --input-shadow-focus: 0 0 0 var(--shadow-spread) #c5b0fc, var(--shadow-inset) !important;
28
+ --input-border-color-focus: #c5b0fc !important;
29
+
30
+ --background-fill-primary: var(--dark-purple) !important;
31
+
32
+ --block-background-fill: var(--dark-purple) !important;
33
+ }
34
+
35
+ @-webkit-keyframes popUp {
36
+ from {
37
+ opacity: 0;
38
+ }
39
+ to {
40
+ opacity: 1;
41
+ }
42
+ }
43
+
44
+ @keyframes popUp {
45
+ from {
46
+ opacity: 0;
47
+ }
48
+ to {
49
+ opacity: 1;
50
+ }
51
+ }
52
+
53
+ .dark {
54
+ --font: "Lexend", sans-serif !important;
55
+ --dark-purple: #242038 !important;
56
+ --button-secondary-background-fill: #c5b0fc !important;
57
+ --button-secondary-background-fill-hover: #a288e3 !important;
58
+ --button-secondary-border-color: var(--dark-purple) !important;
59
+ --border-color-primary: #9067c6 !important;
60
+
61
+ --slider-color: #c5b0fc !important;
62
+ --block-title-text-color: #fafaff !important;
63
+ --input-background-fill: var(--dark-purple) !important;
64
+ --neutral-800: #fafaff !important;
65
+
66
+ --checkbox-label-background-fill: var(--dark-purple) !important;
67
+ --checkbox-label-background-fill-hover: var(--dark-purple) !important;
68
+ --checkbox-background-color: #a288e3 !important;
69
+ --checkbox-border-color: #a288e3 !important;
70
+ --checkbox-background-color-hover: #c5b0fc !important;
71
+ --checkbox-background-color-selected: var(--dark-purple) !important;
72
+ --checkbox-border-color-focus: var(--dark-purple) !important;
73
+ --checkbox-border-color-selected: #c5b0fc !important;
74
+ --shadow-spread: 3px !important;
75
+ --shadow-inset: rgba(0, 0, 0, 0.05) 0px 2px 4px 0px inset !important;
76
+ --shadow-drop: 0px !important;
77
+ --input-shadow-focus: 0 0 0 var(--shadow-spread) #c5b0fc, var(--shadow-inset) !important;
78
+ --input-border-color-focus: #c5b0fc !important;
79
+
80
+ --background-fill-primary: var(--dark-purple) !important;
81
+ --block-background-fill: var(--dark-purple) !important;
82
+ }
83
+
84
+ .gradio-container {
85
+ background-color: var(--dark-purple) !important;
86
+ }
87
+
88
+ .svelte-vt1mxs {
89
+ background-color: var(--dark-purple) !important;
90
+ }
91
+
92
+ .block.svelte-mppz8v {
93
+ background-color: var(--dark-purple) !important;
94
+ }
95
+
96
+ .selected.svelte-1g805jl {
97
+ background: var(--border-color-primary) !important;
98
+ }
99
+
100
+ .svelte-1g805jl button:focus {
101
+ background: var(--dark-purple) !important;
102
+ }
103
+ .svelte-1g805jl button {
104
+ background: #211a1d !important;
105
+ }
106
+ .svelte-1g805jl button:hover {
107
+ color: #ffff !important;
108
+ }
109
+
110
+ [class*="form"][class*="svelte"] {
111
+ border: none !important;
112
+ border-radius: 0px !important;
113
+ }
114
+
115
+ #filtering > span,
116
+ #pixiv > span,
117
+ #pixiv-filters > span,
118
+ #imageControl > span,
119
+ #zeroAIhover > span {
120
+ position: relative;
121
+ z-index: 0;
122
+ }
123
+
124
+ #filtering [data-testid="checkbox-group"] > label > span,
125
+ #pixiv [data-testid="checkbox-group"] > label > span,
126
+ #pixiv-filters [data-testid="checkbox-group"] > label > span,
127
+ #imageControl [data-testid="checkbox-group"] > label > span,
128
+ #zeroAIhover [data-testid="checkbox-group"] > label > span {
129
+ position: relative;
130
+ }
131
+
132
+ #filtering [data-testid="checkbox-group"] > label > span::after,
133
+ #pixiv [data-testid="checkbox-group"] > label > span::after,
134
+ #pixiv-filters [data-testid="checkbox-group"] > label > span::after,
135
+ #imageControl [data-testid="checkbox-group"] > label > span::after,
136
+ #zeroAIhover [data-testid="checkbox-group"] > label > span::after {
137
+ position: absolute;
138
+ z-index: 1;
139
+ visibility: hidden;
140
+ background-color: #c5b0fc;
141
+ color: #fff;
142
+ padding: 5px;
143
+ border-radius: 5px;
144
+ font-size: 12px;
145
+ bottom: 150%;
146
+ left: 50%;
147
+ transform: translateX(-50%);
148
+ white-space: nowrap;
149
+ }
150
+
151
+ #filtering [data-testid="checkbox-group"] > label > span::before,
152
+ #pixiv [data-testid="checkbox-group"] > label > span::before,
153
+ #pixiv-filters [data-testid="checkbox-group"] > label > span::before,
154
+ #imageControl [data-testid="checkbox-group"] > label > span::before,
155
+ #zeroAIhover [data-testid="checkbox-group"] > label > span::before {
156
+ content: "";
157
+ position: absolute;
158
+ visibility: hidden;
159
+ bottom: 105%;
160
+ left: 50%;
161
+ margin-left: -5px;
162
+ border-width: 5px;
163
+ border-style: solid;
164
+ border-color: #c5b0fc transparent transparent transparent;
165
+ }
166
+
167
+ #filtering [data-testid="checkbox-group"] > label:nth-child(6) > span::after,
168
+ #zeroAIhover [data-testid="checkbox-group"] > label:nth-child(1) > span::after,
169
+ #pixiv-filters [data-testid="checkbox-group"] > label:nth-child(4) > span::after {
170
+ content: "AI to download 'good' images";
171
+ }
172
+
173
+ #filtering [data-testid="checkbox-group"] > label:nth-child(5) > span::after {
174
+ content: "General (SFW) images only";
175
+ }
176
+
177
+ #filtering [data-testid="checkbox-group"] > label:nth-child(4) > span::after {
178
+ content: "Allows questionable images";
179
+ }
180
+
181
+ #filtering [data-testid="checkbox-group"] > label:nth-child(3) > span::after {
182
+ content: "Removes explicit images only";
183
+ }
184
+
185
+ #filtering [data-testid="checkbox-group"] > label:nth-child(2) > span::after {
186
+ content: "Images must include all tags given";
187
+ }
188
+
189
+ #filtering [data-testid="checkbox-group"] > label:nth-child(1) > span::after {
190
+ content: "Order by score";
191
+ }
192
+
193
+ #filtering [data-testid="checkbox-group"] > label > span:hover::after,
194
+ #filtering [data-testid="checkbox-group"] > label > span:hover::before,
195
+ #pixiv [data-testid="checkbox-group"] > label > span:hover::after,
196
+ #pixiv [data-testid="checkbox-group"] > label > span:hover::before,
197
+ #pixiv-filters [data-testid="checkbox-group"] > label > span:hover::after,
198
+ #pixiv-filters [data-testid="checkbox-group"] > label > span:hover::before,
199
+ #imageControl [data-testid="checkbox-group"] > label > span:hover::after,
200
+ #imageControl [data-testid="checkbox-group"] > label > span:hover::before,
201
+ #zeroAIhover [data-testid="checkbox-group"] > label > span:hover::after,
202
+ #zeroAIhover [data-testid="checkbox-group"] > label > span:hover::before {
203
+ visibility: visible;
204
+ -webkit-animation: popUp 500ms;
205
+ animation: popUp 500ms;
206
+ }
207
+
208
+ #filtering [data-testid="checkbox-group"] > label:nth-child(3):hover > span {
209
+ color: #e71d36;
210
+ }
211
+ #filtering [data-testid="checkbox-group"] > label:nth-child(4):hover > span {
212
+ color: #ffd151;
213
+ }
214
+ #filtering [data-testid="checkbox-group"] > label:nth-child(5):hover > span {
215
+ color: #21fa90;
216
+ }
217
+
218
+ #pixiv [data-testid="checkbox-group"] > label:nth-child(1) > span::after {
219
+ content: "Downloads the previews";
220
+ }
221
+
222
+ #pixiv [data-testid="checkbox-group"] > label:nth-child(2) > span::after {
223
+ content: "Downloads through the grid";
224
+ }
225
+
226
+ #pixiv-filters [data-testid="checkbox-group"] > label:nth-child(1) > span::after {
227
+ content: "Downloads native image resolution";
228
+ font-size: 0.5rem;
229
+ }
230
+ #pixiv-filters [data-testid="checkbox-group"] > label:nth-child(2) > span::after,
231
+ #imageControl [data-testid="checkbox-group"] > label:nth-child(1) > span::after {
232
+ content: "Continues Search if hangup occurs";
233
+ }
234
+
235
+ #pixiv-filters [data-testid="checkbox-group"] > label:nth-child(3) > span::after {
236
+ content: "Starts from the oldest images";
237
+ }
238
+
239
+ #viewing-restrictions [data-testid="checkbox-group"] > label:nth-child(1):hover span {
240
+ color: #21fa90;
241
+ }
242
+
243
+ #viewing-restrictions [data-testid="checkbox-group"] > label:nth-child(2):hover span {
244
+ color: #e71d36;
245
+ }
246
+
247
+ #button-row {
248
+ display: flex;
249
+ justify-content: center;
250
+ align-items: center;
251
+ }