From c80cc114b6ee045c8e6294e0d8b8020a4ae490e1 Mon Sep 17 00:00:00 2001 From: Castro0o Date: Mon, 20 Apr 2015 08:43:35 +0200 Subject: [PATCH] video to iframes --- allworks_mmdc.json | 2 +- mmdc_modules.py | 27 +++++++++++++---------- mmdc_pages.py | 55 ++++++++++++++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 32 deletions(-) diff --git a/allworks_mmdc.json b/allworks_mmdc.json index 139d1a5..e6fd323 100644 --- a/allworks_mmdc.json +++ b/allworks_mmdc.json @@ -1 +1 @@ -{"9264": {"Website": "http://pwd.io/guide/", "Description": "It\u2019s everybody\u2019s dream to rule a repressive state, but how can this be done in the digital era? This presentation focuses on all the best tips and tricks for keeping control of your population using the Internet. It\u2019s an easy-to-follow, step-by-step guide highlighting all the best practices of what dictators should do in difficult situations. It will accompany you in the obliteration of political dissidence. By having everyone agree with you, or having people believe that everyone else agrees with you, your stay at the top will be long and prosperous. Hard copies of the guide will be available too.", "Creator": "Laurier Rochon,", "Title": "The_Dictator\u2019s_Practical_Internet_Guide_to_Power_Retention", "Thumbnail_url": "http://pzwiki.wdka.nl/mw-mediadesign/images/f/fe/Lr_media1.jpg", "Date": "2012", "Thumbnail": "Lr media1.jpg", "Extra": "{{vimeo|44977056}}

The Dictator's Practical Guide to Internet Power Retention, Global Edition is a wry little 45-page booklet that is, superfically, a book of practical advice for totalitarian, autocratic and theocratic dictators who are looking for advice on how to shape their countries' Internet policy to ensure that the network doesn't loosen their grip on power.

Really, though, this is Laurier Rochon's very good critique of the state of Internet liberation technologies -- a critical analysis of what works, what needs work, and what doesn't work in the world of networked technologies that hope to serve as a force for democratization and self-determination.[http://boingboing.net/2012/08/22/the-dictators-practical-guid.html Cory Doctorow on boingboing...]

[http://www.lulu.com/shop/laurier-rochon/the-dictators-practical-internet-guide-to-power-retention/paperback/product-20216278.html lulu] [http://www.scribd.com/doc/105882261/THE-DICTATOR-S-PRACTICAL-INTERNET-GUIDE-TO-POWER-RETENTION scribd]"}, "9257": {"Description": "(re)describe is an immersive video installation that focuses on re-drawing physical spaces. This visualization, displayed on a 270 degree screen surrounding the audience, presents glimpses of the recognizable amidst an array of abstract images -sourced, generated and manipulated from physical spaces.", "Creator": "Sebastian Cimpean,", "Title": "(re)describe", "Thumbnail_url": "http://pzwiki.wdka.nl/mw-mediadesign/images/thumb/a/af/Redescribe_still1.jpg/500px-Redescribe_still1.jpg", "Date": "2012", "Thumbnail": "redescribe_still1.jpg", "Extra": "{{vimeo|46940365}}File:ReDescribe.jpg|photo by: Janis KlimanovsFile:redescribe_still1.jpgFile:redescribe_still2.jpgFile:redescribe_still3.jpgFile:redescribe_still4.jpgFile:redescribe_still5.jpgThis process started with a series of experiments: testing various software, hardware and techniques within the framework of the concept. The experiments allowed me to test the limitations of my tools and allowed me to understand the extent of what is achievable within the set parameters. Each experiment is documented and analyzed in terms of the ultimate goal of the project - perception of space. This process represents my practice based research.The research conducted weaved between various fields and subjects including the phenomenon of projected visuals, art theory, 360 degree panoramas, performances and happenings, as well as works that combine engineering, technology and art. The project was inspired by the idea of dimensions and Edwin A. Abbott\u2019s satirical novella Flatland and was synthesized within a framework of simple geometry.The following pages are a report of how this project came to life, explaining the various shapes and forms it has been through, the experiments and research that were conducted and the final form of the project as it will be presented in TENT Gallery in Rotterdam."}, "9234": {"Website": "http://pzwart3.wdka.hro.nl/wiki/User:Fako_Berkers/Fako_Berkers,_WWWonopo.ly,_2012", "Description": "People will immediately recognize the game as a variant upon Monopoly. However the streets don't represent streets in Atlantis City or any other city in the world. Instead they portray internet platforms like Facebook, Windows Live, Youtube and Twitter. When you buy part of a set you actually buy shares, bonds or derivates from these web services and although you can't buy houses or hotels you're able to buy \u201cdata storages\u201d and \u201cdata centers\u201d.", "Creator": "Fako Berkers,", "Title": "WWWonopo.ly", "Thumbnail_url": "http://pzwiki.wdka.nl/mw-mediadesign/images/thumb/c/ce/WWWonopoly_Board.png/500px-WWWonopoly_Board.png", "Date": "2012", "Thumbnail": "WWWonopoly Board.png", "Extra": "File:WWWonopoly Board.pngImage:monopoly_logoboxed.pngImage:communitychest.pngImage:platform.pngImage:offline.pngImage:provider.pngFile:Wwwonopoly.png[http://pzwart3.wdka.hro.nl/django/fberkers/finalthesis/hyperdocument/online-privacy/page/the-game Read the full Thesis]By staying very close to the game of Monopoly everybody can engage with the work immediately. Funny anecdotes about how people loose their privacy online are included through the \u201cchance\u201d and \u201ccommunity chest\u201d cards. At the same time the digital part of the game demonstrates how something as innocent as a visit to a news site, gets tracked and used to make a profit, possibly at the expanse of the visitor.People often enjoy social media, but they can't assess the risk tied to them very well. WWWonopo.ly aims to make these risks visible and tangible, in a playful, funny and confronting manner. == Links ==* http://v2.infrae.com/archive/works/wwwonopo.ly/"}, "9230": {"Website": "http://monoskop.org/", "Description": "Monoskop is a collaborative wiki research on the history of media art and culture.", "Creator": "Du\u0161an Barok", "Title": "Monoskop_Library", "Thumbnail_url": "http://pzwiki.wdka.nl/mw-mediadesign/images/d/d1/Monoskop_Logo.png", "Date": "2012", "Thumbnail": "Monoskop Logo.png"}} \ No newline at end of file +{"9264": {"Website": "http://pwd.io/guide/", "Description": "It\u2019s everybody\u2019s dream to rule a repressive state, but how can this be done in the digital era? This presentation focuses on all the best tips and tricks for keeping control of your population using the Internet. It\u2019s an easy-to-follow, step-by-step guide highlighting all the best practices of what dictators should do in difficult situations. It will accompany you in the obliteration of political dissidence. By having everyone agree with you, or having people believe that everyone else agrees with you, your stay at the top will be long and prosperous. Hard copies of the guide will be available too.", "Creator": "Laurier Rochon,", "Title": "The_Dictator\u2019s_Practical_Internet_Guide_to_Power_Retention", "Thumbnail_url": "http://pzwiki.wdka.nl/mw-mediadesign/images/f/fe/Lr_media1.jpg", "Date": "2012", "Thumbnail": "Lr media1.jpg", "Extra": "{{vimeo|44977056}}

The Dictator's Practical Guide to Internet Power Retention, Global Edition is a wry little 45-page booklet that is, superfically, a book of practical advice for totalitarian, autocratic and theocratic dictators who are looking for advice on how to shape their countries' Internet policy to ensure that the network doesn't loosen their grip on power.

Really, though, this is Laurier Rochon's very goo{{youtube|XEVlyP4_11M}}d critique of the state of Internet liberation technologies -- a critical analysis of what works, what needs work, and what doesn't work in the world of networked technologies that hope to serve as a force for democratization and self-determination.[http://boingboing.net/2012/08/22/the-dictators-practical-guid.html Cory Doctorow on boingboing...]

[http://www.lulu.com/shop/laurier-rochon/the-dictators-practical-internet-guide-to-power-retention/paperback/product-20216278.html lulu] [http://www.scribd.com/doc/105882261/THE-DICTATOR-S-PRACTICAL-INTERNET-GUIDE-TO-POWER-RETENTION scribd]"}, "9257": {"Description": "(re)describe is an immersive video installation that focuses on re-drawing physical spaces. This visualization, displayed on a 270 degree screen surrounding the audience, presents glimpses of the recognizable amidst an array of abstract images -sourced, generated and manipulated from physical spaces.", "Creator": "Sebastian Cimpean,", "Title": "(re)describe", "Thumbnail_url": "http://pzwiki.wdka.nl/mw-mediadesign/images/thumb/a/af/Redescribe_still1.jpg/500px-Redescribe_still1.jpg", "Date": "2012", "Thumbnail": "redescribe_still1.jpg", "Extra": "{{vimeo|46940365}}File:ReDescribe.jpg|photo by: Janis KlimanovsFile:redescribe_still1.jpgFile:redescribe_still2.jpgFile:redescribe_still3.jpgFile:redescribe_still4.jpgFile:redescribe_still5.jpgThis process started with a series of experiments: testing various software, hardware and techniques within the framework of the concept. The experiments allowed me to test the limitations of my tools and allowed me to understand the extent of what is achievable within the set parameters. Each experiment is documented and analyzed in terms of the ultimate goal of the project - perception of space. This process represents my practice based research.The research conducted weaved between various fields and subjects including the phenomenon of projected visuals, art theory, 360 degree panoramas, performances and happenings, as well as works that combine engineering, technology and art. The project was inspired by the idea of dimensions and Edwin A. Abbott\u2019s satirical novella Flatland and was synthesized within a framework of simple geometry.The following pages are a report of how this project came to life, explaining the various shapes and forms it has been through, the experiments and research that were conducted and the final form of the project as it will be presented in TENT Gallery in Rotterdam."}, "9234": {"Website": "http://pzwart3.wdka.hro.nl/wiki/User:Fako_Berkers/Fako_Berkers,_WWWonopo.ly,_2012", "Description": "People will immediately recognize the game as a variant upon Monopoly. However the streets don't represent streets in Atlantis City or any other city in the world. Instead they portray internet platforms like Facebook, Windows Live, Youtube and Twitter. When you buy part of a set you actually buy shares, bonds or derivates from these web services and although you can't buy houses or hotels you're able to buy \u201cdata storages\u201d and \u201cdata centers\u201d.", "Creator": "Fako Berkers,", "Title": "WWWonopo.ly", "Thumbnail_url": "http://pzwiki.wdka.nl/mw-mediadesign/images/thumb/c/ce/WWWonopoly_Board.png/500px-WWWonopoly_Board.png", "Date": "2012", "Thumbnail": "WWWonopoly Board.png", "Extra": "File:WWWonopoly Board.pngImage:monopoly_logoboxed.pngImage:communitychest.pngImage:platform.pngImage:offline.pngImage:provider.pngFile:Wwwonopoly.png[http://pzwart3.wdka.hro.nl/django/fberkers/finalthesis/hyperdocument/online-privacy/page/the-game Read the full Thesis]By staying very close to the game of Monopoly everybody can engage with the work immediately. Funny anecdotes about how people loose their privacy online are included through the \u201cchance\u201d and \u201ccommunity chest\u201d cards. At the same time the digital part of the game demonstrates how something as innocent as a visit to a news site, gets tracked and used to make a profit, possibly at the expanse of the visitor.People often enjoy social media, but they can't assess the risk tied to them very well. WWWonopo.ly aims to make these risks visible and tangible, in a playful, funny and confronting manner. == Links ==* http://v2.infrae.com/archive/works/wwwonopo.ly/"}, "9230": {"Website": "http://monoskop.org/", "Description": "Monoskop is a collaborative wiki research on the history of media art and culture.", "Creator": "Du\u0161an Barok", "Title": "Monoskop_Library", "Thumbnail_url": "http://pzwiki.wdka.nl/mw-mediadesign/images/d/d1/Monoskop_Logo.png", "Date": "2012", "Thumbnail": "Monoskop Logo.png"}} diff --git a/mmdc_modules.py b/mmdc_modules.py index 0c02906..bb4054e 100644 --- a/mmdc_modules.py +++ b/mmdc_modules.py @@ -20,7 +20,6 @@ def api_request(action, pagename): #get page: content, metadata, images, imageif return page_content def api_page(pageid, query): - print 'API query:', query if query == 'content': api_response = api_request('action=query&pageids={}&prop=revisions&rvprop=content', pageid) response = ((api_response.get('revisions'))[0])['*'] @@ -28,24 +27,28 @@ def api_page(pageid, query): response = api_request('action=query&pageids={}&prop=info', pageid) elif query == 'articleimgs': response = api_request('action=query&pageids={}&prop=images', pageid) + elif query == 'file': + response = api_request('action=query&titles=File:{}&prop=imageinfo&iiprop=url',pageid) + pprint.pprint( response ) elif query == 'imageinfo': pagename = pageid # in imageinfo titles are used instead of id response = api_request('action=query&titles=File:{}&prop=imageinfo&iiprop=url&iiurlwidth=500', pagename) # iiurlwidht dermines with of thumbnail return response -def api_img_url(filename): # get full-size's image url - '''get url of image''' - page_content_dict = api_page(filename, 'fullimage') - if 'imageinfo' in page_content_dict.keys(): - thumburl = ((page_content_dict.get('imageinfo'))[0].get('thumburl')) - return thumburl - +def api_file_url(filename): # get full urls + page_content_dict = api_page(filename, 'file') + if 'imageinfo' in page_content_dict.keys(): + imgurl = ((page_content_dict.get('imageinfo'))[0].get('url')) + return imgurl + else: + return None + def api_thumb_url(filename): '''get thumbnail url of image''' - page_content_dict = api_page(filename, 'imageinfo') - if 'imageinfo' in page_content_dict.keys(): - thumburl = ((page_content_dict.get('imageinfo'))[0].get('thumburl')) - return thumburl + page_content_dict = api_page(filename, 'imageinfo') + if 'imageinfo' in page_content_dict.keys(): + thumburl = ((page_content_dict.get('imageinfo'))[0].get('thumburl')) + return thumburl # http://pzwiki.wdka.nl/mw-mediadesign/api.php?format=json&action=query&titles=File:2x2 905.jpg&prop=imageinfo&iiprop=url&iiurlwidth=300 diff --git a/mmdc_pages.py b/mmdc_pages.py index b718198..6ff1171 100755 --- a/mmdc_pages.py +++ b/mmdc_pages.py @@ -6,7 +6,7 @@ ##### import xml.etree.ElementTree as ET import html5lib, urllib2, json, pprint, re -from mmdc_modules import api_thumb_url, pandoc2html, img_fullurl +from mmdc_modules import api_thumb_url, pandoc2html, img_fullurl, api_file_url #import mmdc_create_json import api_thumb_url json_allworks_file = open('allworks_mmdc.json', 'r') # save json json_allworks = json.loads(json_allworks_file.read()) @@ -15,8 +15,8 @@ pages_path = 'web/work' #def generate_xml(): gallery_exp=re.compile('.*?') file_exp=re.compile('File:(.*?)(?=File:|<\/gallery>)') -#img_exp=re.compile('(^.*?\.(gif|jpg|jpeg|png))', re.I) -img_exp=re.compile('File:((.*?)\.(gif|jpg|jpeg|png))(?=\||File:|<\/gallery>)', re.I) +img_exp=re.compile('(File:|Image:)((.*?)\.(gif|jpg|jpeg|png))(?=\||File:|Image:|<\/gallery>)', re.I) +video_exp=re.compile('\{\{(.*?)\|(.*?)\}\}') def replace_gallery(content): # from .* imgs, return list of img ET elements @@ -24,19 +24,37 @@ def replace_gallery(content): gallery_imgs = [] gallery_found = re.findall(gallery_exp, content) content = re.sub(gallery_exp, '', content) - print 'gallery_found', gallery_found for gallery in gallery_found: # in case there is more than 1 - print 'GALLERY', gallery allfiles =re.findall(img_exp, gallery) - print 'ALLFILES', allfiles for imgfile in allfiles: - imgfile = imgfile[0] - imgsrc = api_thumb_url(imgfile) # search for original image - print imgfile, imgsrc + imgfile = imgfile[1] + imgsrc = api_file_url(imgfile) # search for original image img_el = ET.Element('img', attrib={'src': imgsrc}) gallery_imgs.append(img_el) -# print 'gallery img', imgfile, ET.tostring(img_el) return content, gallery_imgs + +def replace_video(content): + print '-- Replacing Videos --' + videos = [] + videos_found = re.findall(video_exp, content) + for video in videos_found: + video_provider = str(video[0]) + video_hash = str(video[1]) + video_src = None + print video_provider, type(video_provider) + + if (video_provider.lower()) == 'youtube': + video_src="https://www.youtube.com/embed/" + video_hash + elif (video_provider.lower()) == 'vimeo': + video_src="https://player.vimeo.com/video/" + video_hash + print 'VIMEO' + + if video_src: + iframe_el = ET.Element('iframe', attrib={'src':video_src, 'width':'600px', 'height':'450px'}) + + videos.append(iframe_el) + content = re.sub(video_exp, '', content) + return content, videos def create_workpage( allworks_dict, work_key): # replace text content in dict with html nodes, holding the content for key in allworks_dict.keys(): @@ -44,17 +62,16 @@ def create_workpage( allworks_dict, work_key): # replace text content in dict wi mw_content = allworks_dict[key] if re.search(gallery_exp, mw_content): mw_content, gallery_imgs = replace_gallery(mw_content) - print gallery_imgs - print mw_content.encode('utf-8') - - - + allworks_dict['Images'] = gallery_imgs + elif re.search(video_exp, mw_content): + print '-- Searching for Video --' + mw_content, videos = replace_video(mw_content) + allworks_dict['Video'] = videos + print mw_content, videos + allworks_dict[key] = pandoc2html( mw_content if key in allworks_dict.keys() else '' ) # convert to HTML - # print 'allworks_dict[key]', key#, allworks_dict[key] work_htmltree = html5lib.parseFragment(allworks_dict[key], namespaceHTMLElements=False) -# replace_gallery(work_htmltree) - # print work_htmltree # print ET.tostring(work_htmltree) @@ -80,7 +97,7 @@ def create_workpage( allworks_dict, work_key): # replace text content in dict wi # print work_htmltree allworks_dict[key] = work_htmltree allworks_dict.pop('Thumbnail', None) #remove thumnail -# pprint.pprint(allworks_dict) + pprint.pprint(allworks_dict)