Skip to content
Permalink
Browse files

saving a nonworking solution so that I can fix master

  • Loading branch information...
shawnmjones committed May 14, 2019
1 parent e29629b commit b84f4e6f795ab8f7a25966625eca248a7e4f31cd
@@ -135,7 +135,7 @@ def process_arguments(args):

parser.add_argument('--mementoembed_api', dest='mementoembed_api',
required=False,
default=["http://localhost:5550", "http://mementoembed:5550"],
default=["http://localhost:5000", "http://localhost:5550", "http://mementoembed:5550"],
help="The URL of the MementoEmbed instance used for generating surrogates"
)

@@ -262,6 +262,8 @@ def format_data(input_filename, title, collection_url, generated_by, parser):
# logger.debug("storing generated by value of {}".format(generated_by))
story_data['generated_by'] = generated_by

story_data['metadata'] = {}

story_data['elements'] = []

logger.info("set story title to {}".format(
@@ -146,6 +146,8 @@ def generate_story(self, story_data, mementoembed_api, story_template):

for element in story_elements:

module_logger.debug("working on story element {}".format(element))

try:

if element['type'] == 'link':
@@ -50,6 +50,13 @@ def publish_story(self, story_output_data):

module_logger.info("publishing story as a thread to Twitter")

module_logger.critical(
"story_output_data: {}".format(pprint.pformat(story_output_data))
)

module_logger.critical("premature exit!")
sys.exit(255)

module_logger.debug("main tweet data:\n{}".format(
story_output_data["main_post"]
))
@@ -90,7 +97,7 @@ def publish_story(self, story_output_data):
else:
tweet_media.append(media_uri)

module_logger.debug("thread tweet media: \n{}".format(
module_logger.info("thread tweet media: \n{}".format(
tweet_media
))

@@ -32,6 +32,10 @@
"archive_collection_name": "/services/memento/archivedata/",
"archive_collection_uri": "/services/memento/archivedata/",
"best_image_uri": "/services/memento/bestimage/",
"ranked_image_1": "/services/memento/imagedata/",
"ranked_image_2": "/services/memento/imagedata/",
"ranked_image_3": "/services/memento/imagedata/",
"ranked_image_4": "/services/memento/imagedata/",
"title": "/services/memento/contentdata/",
"snippet": "/services/memento/contentdata/",
"memento_datetime": "/services/memento/contentdata/",
@@ -113,12 +117,25 @@ def get_memento_data(template_surrogate_fields, mementoembed_api, urim):
if r.status_code == 200:

if service == '/services/product/thumbnail/':

memento_data['thumbnail'] = png_to_datauri(r.content)

elif service == '/services/memento/imagedata/':
jsondata = r.json()

# module_logger.debug("jsondata for images: \n{}".format(jsondata))

for imagecounter in range(0, len(jsondata['ranked images'])):
memento_data['ranked_image_{}'.format(imagecounter + 1)] = \
jsondata['ranked images'][imagecounter]

else:
for key in r.json():
memento_data[ key.replace('-', '_') ] = r.json()[key]

# TODO: what do we do if not 200? what is one service is 200, but another not?
else:
module_logger.error("failed to retrieve data from endpoint {}".format(endpoint))

memento_data['urim'] = urim
memento_data['creation_time'] = datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
@@ -15,4 +15,6 @@

{# RAINTALE ELEMENT MEDIA #}
{{ element.surrogate.thumbnail }}
{{ element.surrogate.best_image_uri }}
{{ element.surrogate.ranked_image_1 }}
{{ element.surrogate.ranked_image_2 }}
{{ element.surrogate.ranked_image_3 }}

0 comments on commit b84f4e6

Please sign in to comment.
You can’t perform that action at this time.