Skip to content

Commit

Permalink
Merge branch 'unstable'
Browse files Browse the repository at this point in the history
  • Loading branch information
metal3d committed Mar 7, 2012
2 parents 459d0b3 + 687681f commit 8f18657
Show file tree
Hide file tree
Showing 3 changed files with 269 additions and 63 deletions.
33 changes: 30 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ It's possible to use ``multiprocessing`` module or ``threads`` module to handle
q = quvi.Quvi()
q.parse(url)
print q.getproperties()

#urls to parse
url = "http://www.youtube.com/watch?v=..."
url2 = "http://www.youtube.com/watch?v=..."
Expand All @@ -66,7 +66,7 @@ It's possible to use ``multiprocessing`` module or ``threads`` module to handle
processes = []
processes.append( Process(target=getInfo, args=(url,)) )
processes.append( Process(target=getInfo, args=(url2,)) )

#start and join threads
[p.start() for p in processes]
[p.join() for p in processes]
Expand All @@ -75,11 +75,38 @@ It's possible to use ``multiprocessing`` module or ``threads`` module to handle

Both url will be handle in a thread. So this will be about twice quicker than parsing each url one by one.

Another usecase would be to get the properties of the best format available::

from quvi import Quvi

def get_properties_best_quality(url):
q = Quvi()

url = "http://www.youtube.com/watch?v=0gzA6Xzbh1k"
if q.is_supported(url):
formats = q.get_formats(url)
best_format = formats[-1]
q.set_format(best_format)
q.parse(url)
properties = q.get_properties()
return properties
return none

And downloading the video::

def get_video(filename, url):
properties = get_properties_best_quality(url)
if properties is not None:
to_dl = properties["mediaurl"]
filename += properties["filesuffix"]
urlretrieve(to_dl, filename)


-------------------------
Why this python library ?
-------------------------

Because Quvi command line is really nice and I wanted to get youtube, dailymotion, vimeo (etc...) movies information into my python project. Calling "quvi" command line may be used, but having a real library implementation is the best way to have good performances.
Because Quvi command line is really nice and I wanted to get youtube, dailymotion, vimeo (etc...) movies information into my python project. Calling "quvi" command line may be used, but having a real library implementation is the best way to have good performances.

Using Cython is pretty cool

Expand Down
108 changes: 70 additions & 38 deletions src/cquvi.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,92 @@ __author__="Patrice FERLET <metal3d@gmail.com>"
__license__="LGPLv2.1+."

cdef extern from "quvi/quvi.h":

ctypedef struct quvi_t:
pass

ctypedef void* quvi_media_t
ctypedef void* quvi_video_t
ctypedef void* quvi_ident_t
ctypedef void* quvi_callback_status
ctypedef enum QUVIversion:
QUVI_VERSION
#QUVI_VERSION_LONG
#QUVI_VERSION_SCRIPTS
ctypedef enum QUVIcode:
QUVI_OK = 0x00
QUVI_MEM
QUVI_BADHANDLE
QUVI_INVARG
QUVI_CURLINIT
QUVI_LAST
QUVI_MEM
QUVI_BADHANDLE
QUVI_INVARG
QUVI_CURLINIT
QUVI_LAST
QUVI_ABORTEDBYCALLBACK
QUVI_LUAINIT
QUVI_NOLUAWEBSITE,
QUVI_NOLUAUTIL
_INTERNAL_QUVI_LAST
QUVI_LUAINIT
QUVI_NOLUAWEBSITE
QUVI_NOLUAUTIL
_INTERNAL_QUVI_LAST

QUVI_PCRE = 0x40
QUVI_NOSUPPORT
QUVI_NOSUPPORT
QUVI_CALLBACK
QUVI_ICONV
QUVI_LUA
QUVI_ICONV
QUVI_LUA

QUVI_CURL = 0x42
ctypedef enum QUVIstatus:
QUVISTATUS_FETCH
QUVISTATUS_VERIFY
QUVISTATUS_RESOLVE

ctypedef enum QUVIversion:
pass
ctypedef enum QUVIidentProperty:
pass
ctypedef enum QUVIproperty:
QUVIPROP_NONE
QUVIPROP_HOSTID
QUVIPROP_PAGEURL
QUVIPROP_PAGETITLE
QUVIPROP_MEDIAID
QUVIPROP_MEDIAURL
QUVIPROP_MEDIACONTENTLENGTH
QUVIPROP_MEDIACONTENTTYPE
QUVIPROP_FILESUFFIX
QUVIPROP_RESPONSECODE
QUVIPROP_FORMAT
QUVIPROP_STARTTIME
QUVIPROP_MEDIATHUMBNAILURL
QUVIPROP_MEDIADURATION
_QUVIPROP_LAST
ctypedef enum QUVIstatusType:
QUVISTATUSTYPE_PAGE
QUVISTATUSTYPE_CONFIG
QUVISTATUSTYPE_PLAYLIST
QUVISTATUSTYPE_DONE

ctypedef enum QUVIoption:
pass
QUVIOPT_FORMAT
QUVIOPT_NOVERIFY
QUVIOPT_STATUSFUNCTION
QUVIOPT_NORESOLVE
QUVIOPT_CATEGORY
QUVIOPT_FETCHFUNCTION
QUVIOPT_RESOLVEFUNCTION
QUVIOPT_VERIFYFUNCTION

ctypedef enum QUVIcategory:
QUVIPROTO_HTTP
QUVIPROTO_MMS
QUVIPROTO_RTSP
QUVIPROTO_RTMP
QUVIPROTO_ALL

ctypedef enum QUVIinfo:
pass
QUVIINFO_NONE
QUVIINFO_CURL
QUVIINFO_RESPONSECODE

ctypedef enum QUVIproperty:
QUVIPROP_NONE
QUVIPROP_HOSTID
QUVIPROP_PAGEURL
QUVIPROP_PAGETITLE
QUVIPROP_MEDIAID
QUVIPROP_MEDIAURL
QUVIPROP_MEDIACONTENTLENGTH
QUVIPROP_MEDIACONTENTTYPE
QUVIPROP_FILESUFFIX
QUVIPROP_RESPONSECODE
QUVIPROP_FORMAT
QUVIPROP_STARTTIME
QUVIPROP_MEDIATHUMBNAILURL
QUVIPROP_MEDIADURATION
_QUVIPROP_LAST

ctypedef enum QUVIidentProperty:
QUVI_IDENT_PROPERTY_URL
QUVI_IDENT_PROPERTY_DOMAIN
QUVI_IDENT_PROPERTY_FORMATS
#QUVI_IDENT_PROPERTY_CATEGORIES

ctypedef int quvi_word
ctypedef int quvi_byte

Expand Down
Loading

0 comments on commit 8f18657

Please sign in to comment.