Regex - How do I retrieve all youtube embedded block in HTML? - regex

normally, in html, youtube can be presented as
<object width="420" height="315"><param name="movie" value="http://www.youtube.com/v/qvt_Ae1eRPo?version=3&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/qvt_Ae1eRPo?version=3&hl=en_US" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>
My question is that what's the regex that can retrieve this "object" block from a HTML string?
Thanks

/<object.+?<\/object>/mis should work, please note that if you want a proper retrieval of HTML tags and their contents, you should really use a parser

Related

Using variables in blogger posts

I'm using blogger to make a podcast. It works really well, but I find myself copy/pasting a lot of things, when two or three variables and a template would do the job really well.
Most of the posts look like this:
Étude de Exode 6.14-7.13.
<br />
<audio controls>
<source src="file.mp3" type="audio/mpeg">
<embed height="50" width="100" src="file.mp3">
</audio>
<biblia:bible layout="minimal" resource="lsg" width="400" height="600" historyButtons="false" navigationBox="false" resourcePicker="false" shareButton="false" textSizeButton="false" startingReference="Ex6.14-7.13"></biblia:bible>
Where three things change:
the text on top ("Étude de Exode 6.14-7.13." in the example)
the link to the sound file (which is actually data:post.link, but I can't seem to be able to use expr:src there unfortunately)
the references passed to the biblia:bible tag (here 'Ex6.14-7.13')
Is there a way I could use a template and variables for my blog posts instead of copying and changing things manually every time?
You can, however, convert a string object into valid Blogger XML data. So, first, you need to write this object as your post content (make sure you are in the HTML mode):
{
text: "Étude de Exode 6.14-7.13.",
source: "file.mp3",
ref: "Ex6.14-7.13"
}
After that, inside your blog template, find <data:post.body/> then replace with this:
<b:with var='param' expr:value='data:post.body'>
<data:param.text/>
<br/>
<audio controls='controls'>
<source expr:src='data:param.source' type='audio/mpeg'/>
<embed height='50' width='100' expr:src='data:param.source'/>
</audio>
<biblia:bible layout='minimal' resource='lsg' width='400' height='600' historyButtons='false' navigationBox='false' resourcePicker='false' shareButton='false' textSizeButton='false' expr:startingReference='data:param.ref'/>
</b:with>
Here’s the basic concept: https://www.dte.web.id/2018/07/custom-blogger-widget.html
I am not personally familiar with blogger, but it looks like you can create a widget, and assign variables that way:
<html
xmlns = 'http://www.w3.org/1999/xhtml'
xmlns:b = 'http://www.google.com/2005/gml/b'
xmlns:data = 'http://www.google.com/2005/gml/data'
xmlns:expr = 'http://www.google.com/2005/gml/expr'
>
<b:includable id='post' var='post'>
<data:post.title/>
<br />
<audio controls>
<source src="<data:post.file/>" type="audio/mpeg">
<embed height="50" width="100" src="<data:post.file/>">
</audio>
<biblia:bible layout="minimal" resource="lsg" width="400" height="600" historyButtons="false" navigationBox="false" resourcePicker="false" shareButton="false" textSizeButton="false" startingReference="<data:post.reference/>"></biblia:bible>
</b:includable>
and then to use it...
<b:include name='post' data='p' cond='index < 10'/>
This is a total crap shoot though as I have never used blogger personally, this is just from documentation.
I am referencing material from here:
https://support.google.com/blogger/answer/46995?hl=en
http://thoughtsomething.blogspot.com/2009/01/understanding-blogger-template-1.html
http://helplogger.blogspot.com/2014/03/how-to-create-custom-color-and-font-variable-definitions-to-blogger.html

Extract html tag from content:encoded in Yahoo Pipes

This is my pipes: link
I need to get src attribute of the img tag that are inside the content:encoded
This is the content:encoded of the feed:
<p style="text-align:justify;"><img class="alignnone size-full wp-image-49549" src="http://i2.wp.com/heshootshescoores.com/wp-content/uploads/2014/08/nhl.jpg?resize=600%2C400" alt="nhl"/></p>
<p style="text-align:justify;">...etc.
So in this example I would like to extract this link: ttp://i2.wp.com/heshootshescoores.com/wp-content/uploads/2014/08/nhl.jpg?resize=600%2C400
And export this attribute to a new item.media:thumbnail like this
<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/"
url="HERE GOES THE SRC ATTRIBUTE.png"/>
Is it possible to do with Yahoo! Pipes?( I was thinking about regex but I am not familiar and I don't even know where to start.)
Thank You
FU question: https://stackoverflow.com/questions/25605740/add-items-attribute-in-yahoo-pipes
(.*?)(?=src=)src=\"(.*?)\"(.*)
This will work.
See demo.
http://regex101.com/r/bJ6rZ5/3

Get Youtube Id from youtube embed using Regex [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
php regex - find all youtube video ids in string
How can I get the youtube Id from the embed using Regex, even it is in old format or ifarme
example
<iframe width="560" height="315" src="http://www.youtube.com/embed/ghc8cYOA1Vo" frameborder="0" allowfullscreen></iframe>
or
<object width="560" height="315"><param name="movie" value="http://www.youtube.com/v/ghc8cYOA1Vo?hl=en_US&version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ghc8cYOA1Vo?hl=en_US&version=3" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>
please advice,
youtube.com/((v|embed)/)?[a-zA-Z0-9]+
Youtube has recently gone from 10-character IDs to 11 characters, and it's possible that they may eventually increase that number.
Using the regexp youtube[.]com/(v|embed)/([^"?]+), the YouTube ID will be captured in the second group.
DEMO
I tested this regex ((v|embed))\/?[a-zA-Z0-9_-]+ and it works fine

Embedding issuu

I need to embed an issuu document inside a website. The website administrator should be allowed to decide which document is displayed on the frontend.
This is an easy task, using the embed link on the issuu page. But I need to customize some options - for instance, disable sharing, set the dimensions and so on. I cannot rely on the administrators doing this process every time they need to change the document.
I can easily customize the issuu embed code to my taste, and all that I need is the document id. Unfortunately, the id is not included in the issuu page for the document. For instance, the id for this random link happens to be 110209071155-d0ed1d10ac0b40dda80dad24166a76ee, which is nowhere to be found, neither in the URL nor easily inside the page. You have to dig into the embed code to find it.
I thought the issuu API could allow me to get a document id given its URL, but I cannot find anything like this. The closest match is the search API, but if I search for the exact name of the document I get only one match for a different document!
Is there some easy way to be able to embed a document only knowing its URL? Or an easy way for a non techie person to find a document id in the page?
Unfortunate the only way for you to costomize is to pay for the service wich is 39$ for month =/.
You can force a fullscreen mode without ads by using
<body style="margin:0px;padding:0px;overflow:hidden">
<iframe src="YOUR ISSU EMBED" frameborder="0" style="overflow:hidden;height:105%;width:105%;position:absolute;" height="100%" width="100%""></iframe>
</body>
You can embed of course stacks but that isnt showed on Issuu site. This is code (its old code but it works):
<iframe src="http://static.issuu.com/widgets/shelf/index.html?folderId=FOLDERIDamp;theme=theme1&rows=1&thumbSize=large&roundedCorners=true&showTitle=true&showAuthor=false&shadow=true&effect3d=true" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="100%" height="200"></iframe>
FOLDERID is number of 36 chars that you get on address bar when you enter stacks (example: https://issuu.com/username/stacks/FOLDERID). When you replacing that in code you must paste 36 chars in this format 8-4-4-4-12 with - between chars. And voila its working.
You can change theme and other stuffs in code.
The Document ID is found in the HTML source of every document. It is in the og:video meta property.
<meta property="og:video" content="http://static.issuu.com/webembed/viewers/style1/v2/IssuuReader.swf?mode=mini&documentId=XXXXXXXX-XXXXXXXXXXXXX&pageNumber=0">
You can easily handle it by using the DomDocument and DomXPath php classes.
Here is how-to using PHP:
// Your document URL
$url = 'https://issuu.com/proyectotres/docs/proyecto_3_edicion_135';
// Turn off errors, loads the URL as an object and then turn errors on again
libxml_use_internal_errors(true);
$dom = DomDocument::loadHTMLFile($url);
libxml_use_internal_errors(false);
// DomXPath helps find the <meta property="og:video" content="http://hereyoucanfindthedocumentid?documentId=xxxxx-xxxxxxx"/>
$xpath = new DOMXPath($dom);
$meta = $xpath->query("//html/head/meta[#property='og:video']");
// Get the content attribute of the <meta> node and parse its query
$vars = [];
parse_str(parse_url($meta[0]->getAttribute('content'))['query'], $vars);
// Ready. The document ID is here:
$docID = $vars['documentId'];
// You can print it:
echo $docID;
You can try it with the URL of your own Issu document.
You can use the Issuu URL of your document to complete this iframe :
<iframe width="100%" height="283" style="display: block; margin-left: auto; margin-right: auto;" src="https://e.issuu.com/issuu-reader3-embed-files/latest/twittercard.html?u=nantucketchamber&d=program-update1&p=1" frameborder="0" allowfullscreen="allowfullscreen" span="" id="CmCaReT"></iframe>
You just need to replace "nantucketchamber" by a user name and "program-update1" by the file name in the Issuu URL
(for this example the URL is https://issuu.com/nantucketchamber/docs/program-update1)

How can I embed a YouTube video in a Markdown enabled text field?

This is the code I'm trying to embed:
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/jJECepNeCJ0&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jJECepNeCJ0&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
The interesting thing is that this code seems to display the embedded video in the Preview immediately below the form. Once the form is saved, the code snippet is rendered as text.
It works fine for me.
Make sure your code snippet doesn't have four spaces before it.
You're probably going to have to extend whatever markdown filter you're using (assuming django.contrib.markup) to ignore <object> tags.
If you're using some sort of Javascript editor in your form, it may be converting the < to < before it is saved into your database. In this case, you may have to change the editor.