示例#1
0
文件: remote.py 项目: Crak/raspberry
 def __init__(self, xid):
     """"""
     Video.__init__(self)
     self.xid = xid
     bus = self.pipeline.get_bus()
     bus.enable_sync_message_emission()
     bus.connect("sync-message::element", self.on_gst_sync)
示例#2
0
 def __init__(self):
     """"""
     Video.__init__(self)
     logger.debug(" ".join(RASPIVID))
     self.raspivid = subprocess.Popen(RASPIVID, stdout=subprocess.PIPE)
     src = self.pipeline.get_by_name("local")
     src.set_property("fd", self.raspivid.stdout.fileno())
     self.play()
示例#3
0
def findVideos(search, order="date", max_results=5):
    videos = list()

    # Make search query via YouTube Data API
    params = dict()
    params['part'] = 'snippet'
    params['maxResults'] = max_results
    params['order'] = order
    params['q'] = search
    # only search for videos (i.e no channels/playlists)
    params['type'] = 'video'
    params['key'] = API_KEY

    r = requests.get(SEARCH_URL, params)

    data = r.json()

    # Parse JSON result
    for item in data['items']:
        title = item['snippet']['title']
        blurb = item['snippet']['description']
        link = ''.join([VIDEO_URL, item['id']['videoId']])
        author = item['snippet']['channelTitle']
        datePublished = item['snippet']['publishTime']
        thumbnailLink = item['snippet']['thumbnails']['high']['url']

        videos.append(
            Video(title, blurb, link, author, datePublished, thumbnailLink))

    return videos
示例#4
0
 def quit(self):
     """"""
     Video.quit(self)
     self.raspivid.terminate()