Skip to main content

Video Embed Code Cleaner

Project description

Build Status

Cleans and updates your video’s embed code.

Over time, the embed codes used for videos from various providers have changed and evolved, to make them more and more compatible with a broader set of devices.

This is where vecc is useful: it detects the video provider and id from a given embed code, and provides various utilities to clean this code and validate that the video is still available.

Install

Either use pip, which is the easiest way:

$ pip install vecc

Either download the tarball from http://pypi.python.org/pypi/vecc, untar it, and install it manually:

$ python setup.py install

Usage

$ vecc -h
usage: vecc [-h] [--version] {clean,validate} ...

Video Embed Code Cleaner.

optional arguments:
  -h, --help        show this help message and exit
  -t TIMEOUT, --timeout TIMEOUT
                    timeout for the validation (10 seconds by default)
  --version         show program's version number and exit

sub-commands:
  {clean,validate}
    clean           clean the embed code
    validate        validate that the video is still available

Sub-commands

  • clean: takes a video embed code, and returns the video id, provider, and new embed code. Takes an optional -v|--validate parameter, to check if the video is still available.

  • validate: takes a video id and provider, and check if it’s still available.

Return codes

There’s three different return codes possible:

  • 1: Timeout while validating (doing a HEAD request) the video

  • 2: Provider not found

  • 3: The video is not available anymore

Example

$ vecc clean '<object width="480" height="381"><param name="movie" value="http://www.dailymotion.com/swf/k6Lg9UXest3kho5p9X&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/k6Lg9UXest3kho5p9X&related=0" type="application/x-shockwave-flash" width="480" height="381" allowFullScreen="true" allowScriptAccess="always"></embed></object>' -v
video id: k6Lg9UXest3kho5p9X
provider: dailymotion
embed code: <iframe frameborder="0" width="480" height="270" src="http://www.dailymotion.com/embed/video/k6Lg9UXest3kho5p9X"></iframe>
This video is still valid

Providers

Video providers (Google video, Youtube, Vimeo, Dailymotion…) are configured in the vecc/providers.py file.

Each provider configuration consists of:

  • name: youtube

  • link template: string template (that’ll be interpolated with format) used to build the cleaned code. This is the link to the embedded video player. Needs the {video_id} tag.

  • embed template: string template used to build the new embed code. Needs the {video_link} tag.

  • validation template: string template used to build the link used to validate that the video is still available. This is the link to the video itself (as seen on the provider’s website). Needs the {video_id} tag.

  • matches: regular expressions used to “match” a video embed code to a video provider. Must capture the video id.

Changelog

  • v0.11:

    • added a timeout parameter for the validation

    • now uses proper return codes for failures

  • v0.10:

    • fix print in py2 following porting to py3

  • v0.9:

    • use schema-less urls for the default providers

    • make travis use tox

    • provide a wheel package

  • v0.8:

    • compatible python 2.6 to python 3.3

    • 100% test coverage

  • v0.7:

    • dropped allowfullscreen

    • added autoPlay=1&related=0 on video links

  • v0.6:

    • video size of the cleaned embed code is now 480x395

    • all embed codes with iframes use the same format with allowfullscreen=”true”, autoPlay=”1”, related=”0”

  • v0.5:

    • compatibility with python2.6: argparse as a dependency

  • v0.4:

    • compatibility with python2.6: format needs field numbers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vecc-0.11.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

vecc-0.11-py2.py3-none-any.whl (9.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file vecc-0.11.tar.gz.

File metadata

  • Download URL: vecc-0.11.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for vecc-0.11.tar.gz
Algorithm Hash digest
SHA256 959ac4572146b889d654ba4194729b9c266b25c46cee55544d0da3255c1fc7c2
MD5 cfb175e01568acc17504c9ad69002073
BLAKE2b-256 4ccdba3901c9201823e78779689af21ddba86f5335090731b874cd381928d0e1

See more details on using hashes here.

File details

Details for the file vecc-0.11-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for vecc-0.11-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dfa6e2fe47a8d1a51ba740d7e714fded306a6884dd3fc1050dec036d28f288db
MD5 e54734879a08da80995675053f0277e6
BLAKE2b-256 9823c424b7c7409d293b3da8d68ebfa332273f374d60114962b4ae7e8b24aa25

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page