endpoints.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package core
  2. import (
  3. "fmt"
  4. "net/url"
  5. )
  6. func GetNewestArtworksURL(worktype, r18, lastID string) string {
  7. base := "https://www.pixiv.net/ajax/illust/new?limit=30&type=%s&r18=%s&lastId=%s"
  8. return fmt.Sprintf(base, worktype, r18, lastID)
  9. }
  10. func GetDiscoveryURL(mode string, limit int) string {
  11. base := "https://www.pixiv.net/ajax/discovery/artworks?mode=%s&limit=%d"
  12. return fmt.Sprintf(base, mode, limit)
  13. }
  14. func GetDiscoveryNovelURL(mode string, limit int) string {
  15. base := "https://www.pixiv.net/ajax/discovery/novels?mode=%s&limit=%d"
  16. return fmt.Sprintf(base, mode, limit)
  17. }
  18. func GetRankingURL(mode, content, date, page string) string {
  19. base := "https://www.pixiv.net/ranking.php?format=json&mode=%s&content=%s&date=%s&p=%s"
  20. baseNoDate := "https://www.pixiv.net/ranking.php?format=json&mode=%s&content=%s&p=%s"
  21. if date != "" {
  22. return fmt.Sprintf(base, mode, content, date, page)
  23. }
  24. return fmt.Sprintf(baseNoDate, mode, content, page)
  25. }
  26. func GetRankingCalendarURL(mode string, year, month int) string {
  27. base := "https://www.pixiv.net/ranking_log.php?mode=%s&date=%d%02d"
  28. return fmt.Sprintf(base, mode, year, month)
  29. }
  30. func GetUserInformationURL(id string) string {
  31. base := "https://www.pixiv.net/ajax/user/%s?full=1"
  32. return fmt.Sprintf(base, id)
  33. }
  34. func GetUserArtworksURL(id string) string {
  35. base := "https://www.pixiv.net/ajax/user/%s/profile/all"
  36. return fmt.Sprintf(base, id)
  37. }
  38. func GetUserFullArtworkURL(id, ids string) string {
  39. base := "https://www.pixiv.net/ajax/user/%s/profile/illusts?work_category=illustManga&is_first_page=0&lang=en%s"
  40. return fmt.Sprintf(base, id, ids)
  41. }
  42. func GetUserFullNovelURL(id, ids string) string {
  43. base := "https://www.pixiv.net/ajax/user/%s/profile/novels?is_first_page=0&lang=en%s"
  44. return fmt.Sprintf(base, id, ids)
  45. }
  46. func GetUserBookmarksURL(id, mode string, page int) string {
  47. base := "https://www.pixiv.net/ajax/user/%s/illusts/bookmarks?tag=&offset=%d&limit=48&rest=%s"
  48. return fmt.Sprintf(base, id, page*48, mode)
  49. }
  50. func GetFrequentArtworkTagsURL(ids string) string {
  51. base := "https://www.pixiv.net/ajax/tags/frequent/illust?%s"
  52. return fmt.Sprintf(base, ids)
  53. }
  54. func GetFrequentNovelTagsURL(ids string) string {
  55. base := "https://www.pixiv.net/ajax/tags/frequent/novel?%s"
  56. return fmt.Sprintf(base, ids)
  57. }
  58. func GetNewestFromFollowingURL(mode, page string) string {
  59. base := "https://www.pixiv.net/ajax/follow_latest/%s?mode=%s&p=%s"
  60. // TODO: Recheck this URL
  61. return fmt.Sprintf(base, "illust", mode, page)
  62. }
  63. func GetArtworkInformationURL(id string) string {
  64. base := "https://www.pixiv.net/ajax/illust/%s"
  65. return fmt.Sprintf(base, id)
  66. }
  67. func GetArtworkImagesURL(id string) string {
  68. base := "https://www.pixiv.net/ajax/illust/%s/pages"
  69. return fmt.Sprintf(base, id)
  70. }
  71. func GetArtworkRelatedURL(id string, limit int) string {
  72. base := "https://www.pixiv.net/ajax/illust/%s/recommend/init?limit=%d"
  73. return fmt.Sprintf(base, id, limit)
  74. }
  75. func GetArtworkCommentsURL(id string) string {
  76. base := "https://www.pixiv.net/ajax/illusts/comments/roots?illust_id=%s&limit=100"
  77. return fmt.Sprintf(base, id)
  78. }
  79. func GetTagDetailURL(unescapedTag string) string {
  80. base := "https://www.pixiv.net/ajax/search/tags/%s"
  81. return fmt.Sprintf(base, url.PathEscape(unescapedTag))
  82. }
  83. func GetSearchArtworksURL(s map[string]string) string {
  84. // Long.
  85. base := "https://www.pixiv.net/ajax/search/%s/%s?order=%s&mode=%s&ratio=%s&s_mode=%s&wlt=%s&wgt=%s&hlt=%s&hgt=%s&tool=%s&scd=%s&ecd=%s&p=%s"
  86. return fmt.Sprintf(base, s["Category"], s["Name"], s["Order"], s["Mode"], s["Ratio"], s["Smode"], s["Wlt"], s["Wgt"], s["Hlt"], s["Hgt"], s["Tool"], s["Scd"], s["Ecd"], s["Page"])
  87. }
  88. func GetLandingURL(mode string) string {
  89. base := "https://www.pixiv.net/ajax/top/illust?mode=%s"
  90. return fmt.Sprintf(base, mode)
  91. }
  92. func GetNovelURL(id string) string {
  93. base := "https://www.pixiv.net/ajax/novel/%s"
  94. return fmt.Sprintf(base, id)
  95. }
  96. func GetNovelRelatedURL(id string, limit int) string {
  97. base := "https://www.pixiv.net/ajax/novel/%s/recommend/init?limit=%d"
  98. return fmt.Sprintf(base, id, limit)
  99. }
  100. func GetInsertIllustURL(novelid, id string) string {
  101. base := "https://www.pixiv.net/ajax/novel/%s/insert_illusts?id[]=%s"
  102. return fmt.Sprintf(base, novelid, id)
  103. }