Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8a065c5

Browse files
committed
Use a hash of the cast URL and episode title if there is no GUID
1 parent55edeb4 commit8a065c5

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

‎api/api_test.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ var testFeed = []byte(`<?xml version="1.0" encoding="UTF-8"?>
142142
<itunes:explicit>no</itunes:explicit>
143143
<itunes:duration>1:15:36</itunes:duration>
144144
<media:thumbnail url="http://www.jupiterbroadcasting.com/wp-content/uploads/2015/06/bsd-0095-v.jpg" />
145-
<author>BSD, FreeBSD, PCBSD, PC-BSD, OpenBSD, NetBSD, DragonFlyBSD, FreeNAS, pfSense, Interview, Tutorial, ZFS, UFS (Jupiter Broadcasting)</author><media:content url="http://www.podtrac.com/pts/redirect.mp4/201406.jb-dl.cdn.scaleengine.net/bsdnow/2015/bsd-0095.mp4" fileSize="510856278" type="video/mp4" /></item><item><guid>DD438D40-D5A1-4D08-974F-0B3FAF6BDF9C</guid></item><copyright>Copyright Jupiter Broadcasting</copyright><media:credit role="author">Jupiter Broadcasting</media:credit><media:rating>nonadult</media:rating><media:description type="plain">Everything you wanted to know about BSD</media:description></channel>
145+
<author>BSD, FreeBSD, PCBSD, PC-BSD, OpenBSD, NetBSD, DragonFlyBSD, FreeNAS, pfSense, Interview, Tutorial, ZFS, UFS (Jupiter Broadcasting)</author><media:content url="http://www.podtrac.com/pts/redirect.mp4/201406.jb-dl.cdn.scaleengine.net/bsdnow/2015/bsd-0095.mp4" fileSize="510856278" type="video/mp4" /></item>
146+
<item><guid>DD438D40-D5A1-4D08-974F-0B3FAF6BDF9C</guid></item>
147+
<item><title>Where dat GUID at?</title></item>
148+
<copyright>Copyright Jupiter Broadcasting</copyright><media:credit role="author">Jupiter Broadcasting</media:credit><media:rating>nonadult</media:rating><media:description type="plain">Everything you wanted to know about BSD</media:description></channel>
146149
</rss>`)
147150

148151
varatomTestFeed= []byte(`<?xml version="1.0" encoding="utf-8"?>

‎api/crawl.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,16 @@ func (c *crawler) save(job saveJob) bool {
146146
fori:=rangeepisodes {
147147
ep:=episodes[i].(map[string]interface{})
148148
eps[i].CastID=cast.ID
149-
eps[i].GUID=extractGUID(ep,format)
149+
150+
guid:=extractGUID(ep,format)
151+
ifguid=="" {
152+
title,ok:=ep["title"].(string)
153+
ifok {
154+
guid=md5Hash(cast.URL+title)
155+
}
156+
}
157+
158+
eps[i].GUID=guid
150159
eps[i].CrawlTS=ts
151160
feed,_:=json.Marshal(ep)
152161
eps[i].Feed= (*json.RawMessage)(&feed)

‎api/util.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package api
22

33
import (
4+
"crypto/md5"
5+
"encoding/hex"
6+
47
"github.com/Castcloud/castcloud-go-server/Godeps/_workspace/src/github.com/labstack/echo"
58
)
69

@@ -16,3 +19,8 @@ func formContains(c *echo.Context, keys ...string) bool {
1619
}
1720
returntrue
1821
}
22+
23+
funcmd5Hash(strstring)string {
24+
hash:=md5.Sum([]byte(str))
25+
returnhex.EncodeToString(hash[:])
26+
}

‎api/util_test.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package api
22

33
import (
4+
"crypto/md5"
45
"net/http"
56
"testing"
67

@@ -17,3 +18,7 @@ func TestFormContains(t *testing.T) {
1718
c.Request().PostForm.Set("b","val")
1819
assert.True(t,formContains(c,"a","b"))
1920
}
21+
22+
funcTestMD5(t*testing.T) {
23+
assert.Len(t,md5Hash("stuff"),md5.Size*2)
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp