aboutsummaryrefslogtreecommitdiff
path: root/ignis
diff options
context:
space:
mode:
Diffstat (limited to 'ignis')
-rw-r--r--ignis/github.py42
-rw-r--r--ignis/views.py27
2 files changed, 2 insertions, 67 deletions
diff --git a/ignis/github.py b/ignis/github.py
deleted file mode 100644
index a4cae4bf..00000000
--- a/ignis/github.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import requests
-from dotenv import load_dotenv
-import os
-from selenium import webdriver
-from selenium.webdriver.chrome.options import Options as ChromeOptions
-from selenium.webdriver.firefox.options import Options as FirefoxOptions
-from selenium.webdriver.common.by import By
-from selenium.webdriver.support.ui import WebDriverWait
-from selenium.webdriver.support import expected_conditions as EC
-from io import BytesIO
-from PIL import Image
-
-load_dotenv()
-
-def get_cover(url):
- image = requests.get(url).content
- chrome_options = ChromeOptions()
- chrome_options.add_argument("--headless")
- chrome_options.add_argument("--disable-gpu")
-
- firefox_options = FirefoxOptions()
- firefox_options.add_argument("--headless")
-
- driver = webdriver.Chrome(options=chrome_options) if os.getenv("ENVIRONMENT") == 'development' else webdriver.Firefox(options=firefox_options)
-
- driver.get(url)
- try:
- # take screenshot of page - 1280x640
- WebDriverWait(driver, 10).until(
- EC.presence_of_element_located((By.TAG_NAME, 'svg'))
- )
- driver.set_window_size(1280, 640)
- image = driver.get_screenshot_as_png()
- finally:
- driver.quit()
-
- # resize image to 640x320
- image = Image.open(BytesIO(image))
- image = image.resize((640, 320))
- output = BytesIO()
- image.save(output, format='PNG')
- return output.getvalue()
diff --git a/ignis/views.py b/ignis/views.py
index d05b63a7..67201aaf 100644
--- a/ignis/views.py
+++ b/ignis/views.py
@@ -51,33 +51,10 @@ def get_image(request, slug, md5):
@csrf_exempt
def cover_image(request, repository):
- url = 'https://socialify.git.ci/luciferreeves/{}/image?font=KoHo&language=1&name=1&pattern=Floating%20Cogs&theme=Dark'.format(repository)
- # cover_store = ObjectStorage()
- # image_hash = _md5.md5(url.encode()).hexdigest()
- # # if not cover_store.object_exists('github_covers', image_hash):
- # # image = get_cover(url)
- # import requests
- # api_url = "https://url-to-screenshot.p.rapidapi.com/get"
- # querystring = {"url": url, "height":"1280", "mobile":"0", "allocated_time":"2.0", "width":"640", "base64":"0" }
- # headers = {
- # "Accept": "image/png",
- # "X-RapidAPI-Key": "XAeqfAn1TsmshDMloJ7qiewBExHVp1MKic7jsnkNIsvqIjdlN7",
- # "X-RapidAPI-Host": "url-to-screenshot.p.rapidapi.com"
- # }
- # response = requests.request("GET", api_url, headers=headers, params=querystring)
- # image = response.content
- # print(image)
-
- # data = base64.b64encode(image).decode('utf-8')
- # metadata = 'image/png'
+ url = 'https://socialify.git.ci/luciferreeves/{}/png?font=KoHo&language=1&name=1&pattern=Floating%20Cogs&theme=Dark'.format(repository)
image = requests.get(url).content
- return HttpResponse(image, content_type='image/svg+xml')
-
-
- # cover_store.create_object(md5=image_hash, metadata='image/png', data=data, name='github_covers')
- # return HttpResponse(base64.b64decode(cover_store.get_object('github_covers', image_hash).data), content_type='image/png')
- # cover_store.create_object(md5=image_hash, metadata='image/png', data=data, name='github_covers'))
+ return HttpResponse(image, content_type='image/png')
def upload_image(request):
if request.method == 'POST':