mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Minor bug fixing
This commit is contained in:
@ -10,12 +10,7 @@ server {
|
||||
|
||||
location / {
|
||||
proxy_pass http://app:5001;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection keep-alive;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_buffers 8 16k;
|
||||
proxy_buffer_size 16k;
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package builders
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@ -22,7 +21,7 @@ type VimeoBuilder struct {
|
||||
}
|
||||
|
||||
func (v *VimeoBuilder) selectImage(p *vimeo.Pictures, q api.Quality) string {
|
||||
if p == nil || len(p.Sizes) < 1 {
|
||||
if p == nil || len(p.Sizes) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
@ -38,11 +37,11 @@ func (v *VimeoBuilder) queryChannel(feed *api.Feed) (*itunes.Podcast, error) {
|
||||
|
||||
ch, resp, err := v.client.Channels.Get(channelId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to query channel with channelId %s", channelId)
|
||||
}
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return nil, api.ErrNotFound
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, errors.New("invalid http response from video server")
|
||||
return nil, errors.Wrapf(err, "failed to query channel with channelId %s", channelId)
|
||||
}
|
||||
|
||||
podcast := itunes.New(ch.Name, ch.Link, ch.Description, &ch.CreatedTime, nil)
|
||||
@ -60,11 +59,11 @@ func (v *VimeoBuilder) queryGroup(feed *api.Feed) (*itunes.Podcast, error) {
|
||||
|
||||
gr, resp, err := v.client.Groups.Get(groupId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to query group with id %s", groupId)
|
||||
}
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return nil, api.ErrNotFound
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, errors.New("invalid http response from video server")
|
||||
return nil, errors.Wrapf(err, "failed to query group with id %s", groupId)
|
||||
}
|
||||
|
||||
podcast := itunes.New(gr.Name, gr.Link, gr.Description, &gr.CreatedTime, nil)
|
||||
@ -82,11 +81,11 @@ func (v *VimeoBuilder) queryUser(feed *api.Feed) (*itunes.Podcast, error) {
|
||||
|
||||
user, resp, err := v.client.Users.Get(userId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to query user with id %s", userId)
|
||||
}
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return nil, api.ErrNotFound
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, errors.New("invalid http response from video server")
|
||||
return nil, errors.Wrapf(err, "failed to query user with id %s", userId)
|
||||
}
|
||||
|
||||
podcast := itunes.New(user.Name, user.Link, user.Bio, &user.CreatedTime, nil)
|
||||
@ -116,11 +115,7 @@ func (v *VimeoBuilder) queryVideos(getVideos getVideosFunc, podcast *itunes.Podc
|
||||
for {
|
||||
videos, response, err := getVideos(feed.ItemId, &opt)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to query videos")
|
||||
}
|
||||
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("invalid http response %d from vimeo: %s", response.StatusCode, response.Status)
|
||||
return errors.Wrapf(err, "failed to query videos (error %d %s)", response.StatusCode, response.Status)
|
||||
}
|
||||
|
||||
for _, video := range videos {
|
||||
@ -143,7 +138,7 @@ func (v *VimeoBuilder) queryVideos(getVideos getVideosFunc, podcast *itunes.Podc
|
||||
|
||||
_, err = podcast.AddItem(item)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to add episode")
|
||||
return errors.Wrapf(err, "failed to add episode %s (%s)", item.GUID, item.Title)
|
||||
}
|
||||
|
||||
added++
|
||||
|
@ -69,7 +69,7 @@ func (yt *YouTubeBuilder) listPlaylists(id, channelId string) (*youtube.Playlist
|
||||
}
|
||||
|
||||
if len(resp.Items) == 0 {
|
||||
return nil, errors.New("playlist not found")
|
||||
return nil, api.ErrNotFound
|
||||
}
|
||||
|
||||
item := resp.Items[0]
|
||||
@ -157,7 +157,7 @@ func (yt *YouTubeBuilder) queryFeed(feed *api.Feed) (*itunes.Podcast, string, er
|
||||
if feed.LinkType == api.Playlist {
|
||||
playlist, err := yt.listPlaylists(feed.ItemId, "")
|
||||
if err != nil {
|
||||
return nil, "", errors.Wrap(err, "failed to query playlist")
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
link := fmt.Sprintf("https://youtube.com/playlist?list=%s", playlist.Id)
|
||||
|
@ -218,7 +218,7 @@ Host: www.podsync.net`)
|
||||
if err == api.ErrNotFound {
|
||||
code = http.StatusNotFound
|
||||
} else {
|
||||
log.Printf("server error: %v", err)
|
||||
log.Printf("server error (hash id: %s): %v", hashId, err)
|
||||
}
|
||||
|
||||
c.String(code, err.Error())
|
||||
|
Reference in New Issue
Block a user