Skip to content

Commit

Permalink
Move jsony hook proc on top.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceebeel committed Jan 29, 2022
1 parent 4d7371d commit 2be1bf3
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/audius.nim
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@ type
devotional, classical, reggae, podcasts, country,
spokenWord = "Spoken+Word", comedy, blues, kids, audiobooks, latin

#Hook for lib jsony.
proc parseHook*(s: string, i: var int, v: var Audius) =
## Warning: Do not use! This is a hook for jsony lib.
discard

proc renameHook*(v: var Artwork, fieldName: var string) =
## Warning: Do not use! This is a hook for jsony lib.
##
## Rename field: `small` = 150x & 640x, `medium` = 480x, `big` = 1000x & 2000x
if fieldName == "150x150":
fieldName = "small"
elif fieldName == "480x480":
fieldName = "medium"
elif fieldName == "1000x1000":
fieldName = "big"
elif fieldName == "640x":
fieldName = "small"
elif fieldName == "2000x":
fieldName = "big"

# Audius client
proc newAudius*(appName: string = "EXAMPLEAPP"): Audius =
## This create a new `Audius <#Audius>`_ API (v1) client and select a host.
Expand Down Expand Up @@ -294,23 +314,3 @@ iterator tags*(user: User): string =
let query = user.api.get("/users/" & user.id & "/tags")
for tag in query["data"].getStr.split(','):
yield tag

#Hook for lib jsony.
proc parseHook*(s: string, i: var int, v: var Audius) =
## Warning: Do not use! This is a hook for jsony lib.
discard

proc renameHook*(v: var Artwork, fieldName: var string) =
## Warning: Do not use! This is a hook for jsony lib.
##
## Rename field: `small` = 150x & 640x, `medium` = 480x, `big` = 1000x & 2000x
if fieldName == "150x150":
fieldName = "small"
elif fieldName == "480x480":
fieldName = "medium"
elif fieldName == "1000x1000":
fieldName = "big"
elif fieldName == "640x":
fieldName = "small"
elif fieldName == "2000x":
fieldName = "big"

0 comments on commit 2be1bf3

Please sign in to comment.