fix: publish
This commit is contained in:
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@@ -11,7 +11,8 @@
|
||||
"mode": "auto",
|
||||
"program": "${workspaceFolder}/main.go",
|
||||
"args": [
|
||||
"export",
|
||||
"publish",
|
||||
// "export",
|
||||
// https://t.me/yunpanshare/26640
|
||||
// "--alias", "yunpanshare",
|
||||
// https://t.me/Aliyun_4K_Movies/26640
|
||||
@@ -37,8 +38,8 @@
|
||||
// https://t.me/c/2023304596/2277
|
||||
// "--channel", "2023304596",
|
||||
// https://t.me/cgblz/25220
|
||||
"--alias", "cgblz",
|
||||
"--history",
|
||||
// "--alias", "cgblz",
|
||||
// "--history",
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -78,14 +78,19 @@ func publish(_ context.Context, msg publishMsg) error {
|
||||
|
||||
var file string
|
||||
if media.Photo != nil {
|
||||
res.Type = "image/jpg"
|
||||
res.Name = *media.Photo
|
||||
res.Type = "image/jpeg"
|
||||
res.Filename = *media.Photo
|
||||
file = fmt.Sprintf("%d/%s", data.ChannelID, *media.Photo)
|
||||
} else if media.Document != nil {
|
||||
res.Type = media.Document.MimeType
|
||||
res.Name = media.Document.Filename
|
||||
res.Filename = media.Document.Filename
|
||||
file = fmt.Sprintf("%d/%d%s", data.ChannelID, media.AssetID, media.Document.Ext)
|
||||
} else if media.WebPage != nil {
|
||||
data.Content += fmt.Sprintf("\n\n[%s](%s)", media.WebPage.Title, media.WebPage.URL)
|
||||
} else {
|
||||
return errors.New("unknown media type")
|
||||
}
|
||||
|
||||
filepath := filepath.Join(config.C.Output, file)
|
||||
b, err := os.ReadFile(filepath)
|
||||
if err != nil {
|
||||
|
||||
@@ -43,7 +43,7 @@ func Post(pd PostData) error {
|
||||
resp, err := client.R().
|
||||
SetSuccessResult(&createMemoResp).
|
||||
SetBodyJsonMarshal(Memo{
|
||||
Content: fmt.Sprintf("#%s #%d \n%s", pd.ChannelTitle, pd.ChannelID, pd.Content),
|
||||
Content: fmt.Sprintf("#%s #%d \n\n%s", pd.ChannelTitle, pd.ChannelID, pd.Content),
|
||||
Visibility: "PUBLIC",
|
||||
}).
|
||||
Post("api/v1/memos")
|
||||
@@ -85,5 +85,5 @@ func Upload(res Resource) (Resource, error) {
|
||||
return Resource{}, errors.New("post memo failed, body: " + resp.String())
|
||||
}
|
||||
|
||||
return res, nil
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user