You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

api.go 1.3KB

1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package api
  2. import (
  3. "github.com/terorie/yt-mango/data"
  4. "net/http"
  5. "github.com/terorie/yt-mango/apijson"
  6. "github.com/terorie/yt-mango/apiclassic"
  7. )
  8. type API struct {
  9. GrabVideo func(videoID string) *http.Request
  10. ParseVideo func(*data.Video, *http.Response) error
  11. GrabVideoSubtitleList func(videoID string) *http.Request
  12. ParseVideoSubtitleList func(*data.Video, *http.Response) error
  13. GrabChannel func(channelID string) *http.Request
  14. ParseChannel func(*data.Channel, *http.Response) error
  15. GrabChannelPage func(channelID string, page uint) *http.Request
  16. ParseChannelVideoURLs func(*http.Response) ([]string, error)
  17. }
  18. // TODO Fallback option
  19. var Main *API = nil
  20. // TODO: Remove when everything is implemented
  21. var TempAPI = API{
  22. GrabVideo: apiclassic.GrabVideo,
  23. ParseVideo: apiclassic.ParseVideo,
  24. GrabChannel: apiclassic.GrabChannel,
  25. ParseChannel: apiclassic.ParseChannel,
  26. GrabChannelPage: apijson.GrabChannelPage,
  27. ParseChannelVideoURLs: apijson.ParseChannelVideoURLs,
  28. }
  29. var ClassicAPI = API{
  30. GrabVideo: apiclassic.GrabVideo,
  31. ParseVideo: apiclassic.ParseVideo,
  32. GrabChannel: apiclassic.GrabChannel,
  33. ParseChannel: apiclassic.ParseChannel,
  34. }
  35. var JsonAPI = API{
  36. GrabChannelPage: apijson.GrabChannelPage,
  37. ParseChannelVideoURLs: apijson.ParseChannelVideoURLs,
  38. }