30 lines
		
	
	
		
			691 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			691 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from typing import Any, AsyncIterable
 | |
| 
 | |
| from v6d2ctx.context import Explicit
 | |
| 
 | |
| from v6d3music.utils.aextract import aextract
 | |
| from v6d3music.utils.tor_extract import tor_extract
 | |
| 
 | |
| 
 | |
| async def entries_for_url(url: str, tor: bool) -> AsyncIterable[
 | |
|     dict[str, Any]
 | |
| ]:
 | |
|     ef = aextract
 | |
|     if tor:
 | |
|         ef = tor_extract
 | |
|     info = await ef(
 | |
|         {
 | |
|             'logtostderr': True
 | |
|         },
 | |
|         url,
 | |
|         download=False,
 | |
|         process=False
 | |
|     )
 | |
|     if '__error__' in info:
 | |
|         raise Explicit('extraction error\n' + info.get('__error_str__'))
 | |
|     if 'entries' in info:
 | |
|         for entry in info['entries']:
 | |
|             yield entry
 | |
|     else:
 | |
|         yield info | {'url': url}
 |