-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b51f59c
commit 39763f1
Showing
6 changed files
with
109 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
urls.txt | ||
errors.txt | ||
# Don't include compiled python stuff | ||
__pycache__ | ||
*.pyc | ||
|
||
# Don't include build and dist data and files | ||
fpcurator.spec | ||
build | ||
build-all.py | ||
build.bat | ||
dist | ||
|
||
# Don't include python venv data | ||
Include | ||
Lib | ||
Scripts | ||
pyvenv.cfg | ||
|
||
# Don't include generated files from fpcurator | ||
data.json | ||
errors.txt | ||
search | ||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Miniclip definition. Only supports HTML5. | ||
from __main__ import fpclib | ||
from __main__ import re, json | ||
|
||
regex = 'miniclip.com' | ||
|
||
HTML_EMBED = """<body> | ||
<iframe width="100%" height="100%" src="%s"></iframe> | ||
</body> | ||
""" | ||
|
||
GAME_URL = re.compile('game_url: "(.*?)"') | ||
|
||
class Miniclip(fpclib.Curation): | ||
def parse(self, soup): | ||
# Base everything off of application data, which is hopefully more stable than the webpage format | ||
data = json.loads(soup.select_one("#jsonLdSchema").string) | ||
|
||
self.title = data["name"] | ||
self.logo = data["image"] | ||
self.pub = "Miniclip" | ||
# This theoretically could be used to generate more accurate tags, but whatever | ||
self.tags = data["genre"] | ||
self.date = data["datePublished"][:10] | ||
|
||
# Get Description | ||
try: self.desc = soup.select_one(".game-description").text.strip() | ||
except: pass | ||
|
||
# Only HTML5 is supported | ||
self.platform = "HTML5" | ||
self.app = fpclib.BASILISK | ||
|
||
# Get file for Launch Command | ||
url = GAME_URL.search(soup.select(".game-embed-wrapper > script")[1].string)[1] | ||
if url[0] == "/" and url[1] != "/": | ||
url = "http://www.miniclip.com" + url | ||
self.if_url = fpclib.normalize(url) | ||
|
||
self.cmd = fpclib.normalize(self.src) | ||
|
||
def get_files(self): | ||
# Download iframe that ought to be embedded | ||
fpclib.download_all((self.if_url,)) | ||
# Replace all references to https with http | ||
fpclib.replace(self.if_url[7:], "https:", "http:") | ||
# Create file to embed swf | ||
fpclib.write(self.cmd[7:], HTML_EMBED % self.if_url)) | ||
|
||
def save_image(self, url, file_name): | ||
# Surround save image with a try catch loop as some logos cannot be gotten. | ||
try: | ||
fpclib.download_image(url, name=file_name) | ||
except: pass |