当前位置: 首页>>代码示例>>Python>>正文


Python Track.duration方法代码示例

本文整理汇总了Python中track.Track.duration方法的典型用法代码示例。如果您正苦于以下问题:Python Track.duration方法的具体用法?Python Track.duration怎么用?Python Track.duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在track.Track的用法示例。


在下文中一共展示了Track.duration方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_track_from_uri

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import duration [as 别名]
    def create_track_from_uri(self, uri):
        if 'youtube' not in uri:
            return None
            
        m = re.search('http://www.youtube.com/get_video.video_id=(.*?)&t=(.*)',uri)

        client = gdata.youtube.service.YouTubeService()
        client.ssl = False

        entry = client.GetYouTubeVideoEntry(video_id=m.group(1))
        logging.debug("Created track from uri %s in youtubesource", uri)
        #PrintEntryDetails(entry)
        swfuri = entry.GetSwfUrl()

        video_id = m.group(1)
        t = m.group(2)

        track = Track(uri)
        track.title = entry.media.title.text
        track.artist = "YOUTUBE VIDEO"
        track.album = entry.media.category[0].text
        #FIXME add search for author on album?
        track.album_uri = None
        track.duration = int(entry.media.duration.seconds)*1000

        return track     
开发者ID:estock,项目名称:dogvibes,代码行数:28,代码来源:youtubesource.py

示例2: create_track_from_uri

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import duration [as 别名]
    def create_track_from_uri(self, uri):
        uri = SpotifySource.strip_protocol(uri)
        if uri == None:
            return None
        url = "http://ws.spotify.com/lookup/1/?uri=" + uri

        try:
            e = ET.parse(urllib.urlopen(url))
        except Exception as e:
            return None

        ns = "http://www.spotify.com/ns/music/1"

        if 'album' in uri:
            title = ""
            artist = e.find('.//{%s}artist/{%s}name' % (ns, ns)).text
            album = e.find('.//{%s}name' % ns).text
            duration = 0
            album_uri = uri
        else:
            title = e.find('.//{%s}name' % ns).text
            artist = e.find('.//{%s}artist/{%s}name' % (ns, ns)).text
            album = e.find('.//{%s}album/{%s}name' % (ns, ns)).text
            duration = int(float(e.find('.//{%s}length' % ns).text) * 1000)
            album_uri = "spotify://" + e.find('.//{%s}album' % ns).attrib['href']

        track = Track("spotify://"+uri)
        track.title = title
        track.artist = artist
        track.album = album
        track.album_uri = album_uri
        track.duration = duration

        return track
开发者ID:popdevelop,项目名称:dogvibes_old_svn_master,代码行数:36,代码来源:spotifysource.py

示例3: create_track_from_uri

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import duration [as 别名]
    def create_track_from_uri(self, uri):
        if 'asx' not in uri:
            return None

        logging.debug("Created track from uri %s in srradiosource", uri)
        u = urllib.urlopen(uri)
        str = re.search('\"mms:.+\"', u.read())

        u = open("sr.xml") 
        tree = ET.parse(u)
        u.close()

        track = Track(str.group(0)[1:-1])

        for e in tree.findall('channel'):
            for k in e.findall('streamingurl'):
                for s in k.findall('url'):
                    if uri in s.text:
                        track.title = e.get('name')

        track.artist = "SR RADIOTRACK"
        track.album = "SR RADIOTRACK"
        track.album_uri = None
        track.duration = 1

        return track     
开发者ID:estock,项目名称:dogvibes,代码行数:28,代码来源:srradiosource.py

示例4: create_tracks_from_album

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import duration [as 别名]
 def create_tracks_from_album(self, album):
     tracks = []
     for track in album['tracks']:
         tmptrack = Track(track['uri'])
         tmptrack.title = track['title']
         tmptrack.artist = track['artist']
         tmptrack.album = album['name']
         tmptrack.album_uri = album['uri']
         tmptrack.duration = track['duration']
         tracks.append(tmptrack)
     return tracks
开发者ID:popdevelop,项目名称:dogvibes_old_svn_master,代码行数:13,代码来源:spotifysource.py

示例5: index

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import duration [as 别名]
 def index(self, path):
     for top, dirnames, filenames in os.walk(path):
         for filename in filenames:
             if filename.endswith('.mp3'):
                 full_path = os.path.join(top, filename);
                 f = tagpy.FileRef(full_path)
                 t = Track("file://" + full_path)
                 t.title = f.tag().title
                 t.artist = f.tag().artist
                 t.album = f.tag().album
                 a = f.audioProperties()
                 t.duration = a.length * 1000 # to msec
                 self.add_track(t)
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:15,代码来源:collection.py

示例6: create_track_from_uri

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import duration [as 别名]
    def create_track_from_uri(self, uri):
        url = "http://ws.spotify.com/lookup/1/?uri=" + uri

        try:
            e = ET.parse(urllib.urlopen(url))
        except Exception as e:
            return None

        ns = "http://www.spotify.com/ns/music/1"

        title = e.find('.//{%s}name' % ns).text
        artist = e.find('.//{%s}artist/{%s}name' % (ns, ns)).text
        album = e.find('.//{%s}album/{%s}name' % (ns, ns)).text
        duration = int(float(e.find('.//{%s}length' % ns).text) * 1000)

        track = Track("spotify://"+uri)
        track.title = title
        track.artist = artist
        track.album = album
        track.duration = duration

        return track
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:24,代码来源:spotifysource.py


注:本文中的track.Track.duration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。