基于Micawb的嵌入式视频标题提取

2024-04-26 21:27:32 发布

您现在位置:Python中文网/ 问答频道 /正文

一切都很好,我只是找不到一种方法来实际输出整个文本字段,而只是使用micawber嵌入特定的u'title'变量。你知道吗

from flask import Flask, render_template, flash, request, redirect
from micawber.providers import bootstrap_basic
from micawber.contrib.mcflask import add_oembed_filters

app = Flask(__name__)
oembed_providers = bootstrap_basic()
add_oembed_filters(app, oembed_providers)

@app.route('/example/')
def contact():

    text = request.args.get('text', 'http://www.youtube.com/watch?v=nda_OSWeyn8')

    return render_template("example.html", text=text)
if __name__ == "__main__":
    app.run(debug = True, host='0.0.0.0', port=5000, passthrough_errors=True)

这是金甲二段

   <div class="video-border text-center">
        <div class="embed-responsive embed-responsive-4by3">
      {{ text|oembed(class="embed-responsive-item")  }}
      </div>

      <h5>Video Title</h5>

          {{ text|extract_oembed() }}


    </div>

下面是它在视频标题下给出的输出

([u'http://www.youtube.com/watch?v=nda_OSWeyn8'], {u'http://www.youtube.com/watch?v=nda_OSWeyn8': {u'provider_url': u'http://www.youtube.com/', u'version': u'1.0', u'title': u'Leprechaun in Mobile, Alabama', 'url': u'http://www.youtube.com/watch?v=nda_OSWeyn8', u'type': u'video', u'thumbnail_width': 480, u'height': 344, u'width': 459, u'html': u'<iframe width="459" height="344" src="http://www.youtube.com/embed/nda_OSWeyn8?feature=oembed" frameborder="0" allowfullscreen></iframe>', u'author_name': u'botmib', u'thumbnail_height': 360, u'thumbnail_url': u'http://i.ytimg.com/vi/nda_OSWeyn8/hqdefault.jpg', u'provider_name': u'YouTube', u'author_url': u'http://www.youtube.com/user/botmib'}})

Tags: textnamedivcomapphttpurlyoutube