

+A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation. |
diff --git a/src/TibiaNewsV3.go b/src/TibiaNewsV3.go
index 65fd3674..93ac4a95 100644
--- a/src/TibiaNewsV3.go
+++ b/src/TibiaNewsV3.go
@@ -20,16 +20,13 @@ type News struct {
ContentHTML string `json:"content_html"`
}
-//
// The base
type NewsResponse struct {
News News `json:"news"`
Information Information `json:"information"`
}
-var (
- martelRegex = regexp.MustCompile(`
]+..)`)
-)
+var martelRegex = regexp.MustCompile(`
]+..)`)
func TibiaNewsV3Impl(NewsID int, rawUrl string, BoxContentHTML string) NewsResponse {
// Declaring vars for later use..
@@ -49,7 +46,6 @@ func TibiaNewsV3Impl(NewsID int, rawUrl string, BoxContentHTML string) NewsRespo
NewsData.TibiaURL = rawUrl
ReaderHTML.Find(".NewsHeadline").Each(func(index int, s *goquery.Selection) {
-
// getting category by image src
CategoryImg, _ := s.Find("img").Attr("src")
NewsData.Category = TibiaDataGetNewsCategory(CategoryImg)
@@ -70,12 +66,16 @@ func TibiaNewsV3Impl(NewsID int, rawUrl string, BoxContentHTML string) NewsRespo
})
ReaderHTML.Find(".NewsTableContainer").Each(func(index int, s *goquery.Selection) {
-
// checking if its a ticker..
if NewsData.Type == "ticker" {
tmp1 = s.Find("p")
- NewsData.Content = tmp1.Text()
- NewsData.ContentHTML, _ = tmp1.Html()
+ if tmp1.Text() == "" {
+ NewsData.Content = s.Text()
+ NewsData.ContentHTML, _ = s.Html()
+ } else {
+ NewsData.Content = tmp1.Text()
+ NewsData.ContentHTML, _ = tmp1.Html()
+ }
} else {
// getting html
tmp2, _ = s.First().Html()
diff --git a/src/TibiaNewsV3_test.go b/src/TibiaNewsV3_test.go
index 2e59c870..75924af0 100644
--- a/src/TibiaNewsV3_test.go
+++ b/src/TibiaNewsV3_test.go
@@ -47,6 +47,26 @@ func TestNews6512(t *testing.T) {
assert.Equal("TibiaData.com has some news to share! First of all, they invite you to participate in their Discord Server. Further, they are now present on GitHub. They are working on their v3, which is still in beta. If you are interested in such things, head on over there to see what is cooking.", newsArticleJson.News.ContentHTML)
}
+func TestNews504(t *testing.T) {
+ data, err := os.ReadFile("../testdata/news/archive/504.html")
+ if err != nil {
+ t.Errorf("File reading error: %s", err)
+ return
+ }
+
+ newsArticleJson := TibiaNewsV3Impl(504, "https://www.tibia.com/news/?subtopic=newsarchive&id=504", string(data))
+ assert := assert.New(t)
+
+ assert.Equal(504, newsArticleJson.News.ID)
+ assert.Equal("2007-04-27", newsArticleJson.News.Date)
+ assert.Empty(newsArticleJson.News.Title)
+ assert.Equal("community", newsArticleJson.News.Category)
+ assert.Equal("ticker", newsArticleJson.News.Type)
+ assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=504", newsArticleJson.News.TibiaURL)
+ assert.Equal("A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation.", newsArticleJson.News.Content)
+ assert.Equal("
A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation.", newsArticleJson.News.ContentHTML)
+}
+
func TestNews6481(t *testing.T) {
data, err := os.ReadFile("../testdata/news/archive/6481.html")
if err != nil {
diff --git a/testdata/news/archive/504.html b/testdata/news/archive/504.html
new file mode 100644
index 00000000..4fa10f2e
--- /dev/null
+++ b/testdata/news/archive/504.html
@@ -0,0 +1,778 @@
+
+
+
+


+A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation. |
Access ALL Areas!
