| 
									
										
										
										
											2015-01-21 23:05:47 +08:00
										 |  |  | # coding: utf-8 | 
					
						
							|  |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2015-01-21 22:53:51 +06:00
										 |  |  | from ..compat import compat_str | 
					
						
							|  |  |  | from ..utils import unified_strdate | 
					
						
							| 
									
										
										
										
											2015-01-21 23:05:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class StreetVoiceIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2015-01-21 22:53:51 +06:00
										 |  |  |     _VALID_URL = r'https?://(?:.+?\.)?streetvoice\.com/[^/]+/songs/(?P<id>[0-9]+)' | 
					
						
							|  |  |  |     _TESTS = [{ | 
					
						
							|  |  |  |         'url': 'http://streetvoice.com/skippylu/songs/94440/', | 
					
						
							|  |  |  |         'md5': '15974627fc01a29e492c98593c2fd472', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '94440', | 
					
						
							|  |  |  |             'ext': 'mp3', | 
					
						
							|  |  |  |             'filesize': 4167053, | 
					
						
							|  |  |  |             'title': '輸', | 
					
						
							|  |  |  |             'description': 'Crispy脆樂團 - 輸', | 
					
						
							|  |  |  |             'thumbnail': 're:^https?://.*\.jpg$', | 
					
						
							|  |  |  |             'duration': 260, | 
					
						
							|  |  |  |             'upload_date': '20091018', | 
					
						
							|  |  |  |             'uploader': 'Crispy脆樂團', | 
					
						
							|  |  |  |             'uploader_id': '627810', | 
					
						
							| 
									
										
										
										
											2015-01-21 23:05:47 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-01-21 22:53:51 +06:00
										 |  |  |     }, { | 
					
						
							|  |  |  |         'url': 'http://tw.streetvoice.com/skippylu/songs/94440/', | 
					
						
							|  |  |  |         'only_matching': True, | 
					
						
							|  |  |  |     }] | 
					
						
							| 
									
										
										
										
											2015-01-21 23:05:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         song_id = self._match_id(url) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-21 22:53:51 +06:00
										 |  |  |         song = self._download_json( | 
					
						
							|  |  |  |             'http://streetvoice.com/music/api/song/%s' % song_id, song_id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         title = song['name'] | 
					
						
							|  |  |  |         author = song['musician']['name'] | 
					
						
							| 
									
										
										
										
											2015-01-21 23:05:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             'id': song_id, | 
					
						
							| 
									
										
										
										
											2015-01-21 22:53:51 +06:00
										 |  |  |             'url': song['file'], | 
					
						
							|  |  |  |             'filesize': song.get('size'), | 
					
						
							| 
									
										
										
										
											2015-01-21 23:05:47 +08:00
										 |  |  |             'title': title, | 
					
						
							| 
									
										
										
										
											2015-01-21 22:53:51 +06:00
										 |  |  |             'description': '%s - %s' % (author, title), | 
					
						
							|  |  |  |             'thumbnail': self._proto_relative_url(song.get('image'), 'http:'), | 
					
						
							|  |  |  |             'duration': song.get('length'), | 
					
						
							|  |  |  |             'upload_date': unified_strdate(song.get('created_at')), | 
					
						
							|  |  |  |             'uploader': author, | 
					
						
							|  |  |  |             'uploader_id': compat_str(song['musician']['id']), | 
					
						
							| 
									
										
										
										
											2015-01-21 23:05:47 +08:00
										 |  |  |         } |