mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	Update ExtractorApi.kt
This commit is contained in:
		
							parent
							
								
									9f8bbed6c1
								
							
						
					
					
						commit
						bd52d40773
					
				
					 1 changed files with 23 additions and 3 deletions
				
			
		|  | @ -407,6 +407,26 @@ open class ExtractorLink constructor( | ||||||
|     val isM3u8: Boolean get() = type == ExtractorLinkType.M3U8 |     val isM3u8: Boolean get() = type == ExtractorLinkType.M3U8 | ||||||
|     val isDash: Boolean get() = type == ExtractorLinkType.DASH |     val isDash: Boolean get() = type == ExtractorLinkType.DASH | ||||||
| 
 | 
 | ||||||
|  |     // Cached video size | ||||||
|  |     private var videoSize: Long? = null | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get video size in bytes with one head request. Only available for ExtractorLinkType.Video | ||||||
|  |      * @param timeoutSeconds timeout of the head request. | ||||||
|  |      */ | ||||||
|  |     suspend fun getVideoSize(timeoutSeconds: Long = 3L): Long? { | ||||||
|  |         // Content-Length is not applicable to other types of formats | ||||||
|  |         if (this.type != ExtractorLinkType.VIDEO) return null | ||||||
|  | 
 | ||||||
|  |         videoSize = videoSize ?: runCatching { | ||||||
|  |             val response = | ||||||
|  |                 app.head(this.url, headers = headers, referer = referer, timeout = timeoutSeconds) | ||||||
|  |             response.headers["Content-Length"]?.toLong() | ||||||
|  |         }.getOrNull() | ||||||
|  | 
 | ||||||
|  |         return videoSize | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     @JsonIgnore |     @JsonIgnore | ||||||
|     fun getAllHeaders() : Map<String, String> { |     fun getAllHeaders() : Map<String, String> { | ||||||
|         if (referer.isBlank()) { |         if (referer.isBlank()) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue