Add fix for parsing videos with 1 view

This commit is contained in:
Omar Roth 2018-08-05 14:08:39 -05:00
parent 8c22c226c0
commit e47b95ff42
2 changed files with 4 additions and 4 deletions

View file

@ -2279,12 +2279,12 @@ get "/api/v1/channels/:ucid/videos" do |env|
if metadata.size == 0
next
elsif metadata.size == 1
view_count = metadata[0].content.rchop(" watching").delete(",").to_i64
view_count = metadata[0].content.split(" ")[0].delete(",").to_i64
published = Time.now
else
published = decode_date(metadata[0].content)
view_count = metadata[1].content.rchop(" views")
view_count = metadata[1].content.split(" ")[0]
if view_count == "No"
view_count = 0_i64
else

View file

@ -44,12 +44,12 @@ def search(query, page = 1, search_params = build_search_params(content_type: "v
if metadata.size == 0
next
elsif metadata.size == 1
view_count = metadata[0].content.rchop(" watching").delete(",").to_i64
view_count = metadata[0].content.split(" ")[0].delete(",").to_i64
published = Time.now
else
published = decode_date(metadata[0].content)
view_count = metadata[1].content.rchop(" views")
view_count = metadata[1].content.split(" ")[0]
if view_count == "No"
view_count = 0_i64
else