|
| 1 | +package febbox |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "github.com/alist-org/alist/v3/internal/model" |
| 6 | + "github.com/alist-org/alist/v3/pkg/utils" |
| 7 | + hash_extend "github.com/alist-org/alist/v3/pkg/utils/hash" |
| 8 | + "strconv" |
| 9 | + "time" |
| 10 | +) |
| 11 | + |
| 12 | +type ErrResp struct { |
| 13 | + ErrorCode int64 `json:"code"` |
| 14 | + ErrorMsg string `json:"msg"` |
| 15 | + ServerRunTime float64 `json:"server_runtime"` |
| 16 | + ServerName string `json:"server_name"` |
| 17 | +} |
| 18 | + |
| 19 | +func (e *ErrResp) IsError() bool { |
| 20 | + return e.ErrorCode != 0 || e.ErrorMsg != "" || e.ServerRunTime != 0 || e.ServerName != "" |
| 21 | +} |
| 22 | + |
| 23 | +func (e *ErrResp) Error() string { |
| 24 | + return fmt.Sprintf("ErrorCode: %d ,Error: %s ,ServerRunTime: %f ,ServerName: %s", e.ErrorCode, e.ErrorMsg, e.ServerRunTime, e.ServerName) |
| 25 | +} |
| 26 | + |
| 27 | +type FileListResp struct { |
| 28 | + Code int `json:"code"` |
| 29 | + Msg string `json:"msg"` |
| 30 | + Data struct { |
| 31 | + FileList []File `json:"file_list"` |
| 32 | + ShowType string `json:"show_type"` |
| 33 | + } `json:"data"` |
| 34 | +} |
| 35 | + |
| 36 | +type Rules struct { |
| 37 | + AllowCopy int64 `json:"allow_copy"` |
| 38 | + AllowDelete int64 `json:"allow_delete"` |
| 39 | + AllowDownload int64 `json:"allow_download"` |
| 40 | + AllowComment int64 `json:"allow_comment"` |
| 41 | + HideLocation int64 `json:"hide_location"` |
| 42 | +} |
| 43 | + |
| 44 | +type File struct { |
| 45 | + Fid int64 `json:"fid"` |
| 46 | + UID int64 `json:"uid"` |
| 47 | + FileSize int64 `json:"file_size"` |
| 48 | + Path string `json:"path"` |
| 49 | + FileName string `json:"file_name"` |
| 50 | + Ext string `json:"ext"` |
| 51 | + AddTime int64 `json:"add_time"` |
| 52 | + FileCreateTime int64 `json:"file_create_time"` |
| 53 | + FileUpdateTime int64 `json:"file_update_time"` |
| 54 | + ParentID int64 `json:"parent_id"` |
| 55 | + UpdateTime int64 `json:"update_time"` |
| 56 | + LastOpenTime int64 `json:"last_open_time"` |
| 57 | + IsDir int64 `json:"is_dir"` |
| 58 | + Epub int64 `json:"epub"` |
| 59 | + IsMusicList int64 `json:"is_music_list"` |
| 60 | + OssFid int64 `json:"oss_fid"` |
| 61 | + Faststart int64 `json:"faststart"` |
| 62 | + HasVideoQuality int64 `json:"has_video_quality"` |
| 63 | + TotalDownload int64 `json:"total_download"` |
| 64 | + Status int64 `json:"status"` |
| 65 | + Remark string `json:"remark"` |
| 66 | + OldHash string `json:"old_hash"` |
| 67 | + Hash string `json:"hash"` |
| 68 | + HashType string `json:"hash_type"` |
| 69 | + FromUID int64 `json:"from_uid"` |
| 70 | + FidOrg int64 `json:"fid_org"` |
| 71 | + ShareID int64 `json:"share_id"` |
| 72 | + InvitePermission int64 `json:"invite_permission"` |
| 73 | + ThumbSmall string `json:"thumb_small"` |
| 74 | + ThumbSmallWidth int64 `json:"thumb_small_width"` |
| 75 | + ThumbSmallHeight int64 `json:"thumb_small_height"` |
| 76 | + Thumb string `json:"thumb"` |
| 77 | + ThumbWidth int64 `json:"thumb_width"` |
| 78 | + ThumbHeight int64 `json:"thumb_height"` |
| 79 | + ThumbBig string `json:"thumb_big"` |
| 80 | + ThumbBigWidth int64 `json:"thumb_big_width"` |
| 81 | + ThumbBigHeight int64 `json:"thumb_big_height"` |
| 82 | + IsCustomThumb int64 `json:"is_custom_thumb"` |
| 83 | + Photos int64 `json:"photos"` |
| 84 | + IsAlbum int64 `json:"is_album"` |
| 85 | + ReadOnly int64 `json:"read_only"` |
| 86 | + Rules Rules `json:"rules"` |
| 87 | + IsShared int64 `json:"is_shared"` |
| 88 | +} |
| 89 | + |
| 90 | +func fileToObj(f File) *model.ObjThumb { |
| 91 | + return &model.ObjThumb{ |
| 92 | + Object: model.Object{ |
| 93 | + ID: strconv.FormatInt(f.Fid, 10), |
| 94 | + Name: f.FileName, |
| 95 | + Size: f.FileSize, |
| 96 | + Ctime: time.Unix(f.FileCreateTime, 0), |
| 97 | + Modified: time.Unix(f.FileUpdateTime, 0), |
| 98 | + IsFolder: f.IsDir == 1, |
| 99 | + HashInfo: utils.NewHashInfo(hash_extend.GCID, f.Hash), |
| 100 | + }, |
| 101 | + Thumbnail: model.Thumbnail{ |
| 102 | + Thumbnail: f.Thumb, |
| 103 | + }, |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +type FileDownloadResp struct { |
| 108 | + Code int `json:"code"` |
| 109 | + Msg string `json:"msg"` |
| 110 | + Data []struct { |
| 111 | + Error int `json:"error"` |
| 112 | + DownloadURL string `json:"download_url"` |
| 113 | + Hash string `json:"hash"` |
| 114 | + HashType string `json:"hash_type"` |
| 115 | + Fid int `json:"fid"` |
| 116 | + FileName string `json:"file_name"` |
| 117 | + ParentID int `json:"parent_id"` |
| 118 | + FileSize int `json:"file_size"` |
| 119 | + Ext string `json:"ext"` |
| 120 | + Thumb string `json:"thumb"` |
| 121 | + VipLink int `json:"vip_link"` |
| 122 | + } `json:"data"` |
| 123 | +} |
0 commit comments