Add support for "vmap" videos
This commit is contained in:
		
							parent
							
								
									ac8d0e2052
								
							
						
					
					
						commit
						13dc5efcf6
					
				| 
						 | 
					@ -100,11 +100,25 @@ proc parseConversation*(node: XmlNode): Conversation =
 | 
				
			||||||
 | 
					
 | 
				
			||||||
proc parseVideo*(node: JsonNode): Video =
 | 
					proc parseVideo*(node: JsonNode): Video =
 | 
				
			||||||
  let track = node{"track"}
 | 
					  let track = node{"track"}
 | 
				
			||||||
  result = Video(
 | 
					  let contentType = track["contentType"].to(string)
 | 
				
			||||||
    thumb: node["posterImage"].to(string),
 | 
					
 | 
				
			||||||
    id: track["contentId"].to(string),
 | 
					  case contentType
 | 
				
			||||||
    length: track["durationMs"].to(int),
 | 
					  of "media_entity":
 | 
				
			||||||
    views: track["viewCount"].to(string),
 | 
					    result = Video(
 | 
				
			||||||
    url: track["playbackUrl"].to(string),
 | 
					      contentType: m3u8,
 | 
				
			||||||
    available: track{"mediaAvailability"}["status"].to(string) == "available"
 | 
					      thumb: node["posterImage"].to(string),
 | 
				
			||||||
  )
 | 
					      id: track["contentId"].to(string),
 | 
				
			||||||
 | 
					      length: track["durationMs"].to(int),
 | 
				
			||||||
 | 
					      views: track["viewCount"].to(string),
 | 
				
			||||||
 | 
					      url: track["playbackUrl"].to(string),
 | 
				
			||||||
 | 
					      available: track{"mediaAvailability"}["status"].to(string) == "available"
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					  of "vmap":
 | 
				
			||||||
 | 
					    result = Video(
 | 
				
			||||||
 | 
					      contentType: vmap,
 | 
				
			||||||
 | 
					      thumb: node["posterImage"].to(string),
 | 
				
			||||||
 | 
					      url: track["vmapUrl"].to(string),
 | 
				
			||||||
 | 
					      length: track["durationMs"].to(int),
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					  else:
 | 
				
			||||||
 | 
					    echo "Can't parse video of type ", contentType
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,12 +31,16 @@ db("cache.db", "", "", ""):
 | 
				
			||||||
        .}: Time
 | 
					        .}: Time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type
 | 
					type
 | 
				
			||||||
 | 
					  VideoType* = enum
 | 
				
			||||||
 | 
					    vmap, m3u8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Video* = object
 | 
					  Video* = object
 | 
				
			||||||
    id*: string
 | 
					    contentType*: VideoType
 | 
				
			||||||
    url*: string
 | 
					    url*: string
 | 
				
			||||||
    thumb*: string
 | 
					    thumb*: string
 | 
				
			||||||
    length*: int
 | 
					    id*: string
 | 
				
			||||||
    views*: string
 | 
					    views*: string
 | 
				
			||||||
 | 
					    length*: int
 | 
				
			||||||
    available*: bool
 | 
					    available*: bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Gif* = object
 | 
					  Gif* = object
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue