Stop proxying content
This commit is contained in:
		
							parent
							
								
									48b2690dd9
								
							
						
					
					
						commit
						5acb710739
					
				| 
						 | 
					@ -99,7 +99,6 @@ func parseAlbum(data gjson.Result) (Album, error) {
 | 
				
			||||||
	data.Get("media").ForEach(
 | 
						data.Get("media").ForEach(
 | 
				
			||||||
		func(key gjson.Result, value gjson.Result) bool {
 | 
							func(key gjson.Result, value gjson.Result) bool {
 | 
				
			||||||
			url := value.Get("url").String()
 | 
								url := value.Get("url").String()
 | 
				
			||||||
			url = strings.ReplaceAll(url, "https://i.imgur.com", "")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			description := value.Get("metadata.description").String()
 | 
								description := value.Get("metadata.description").String()
 | 
				
			||||||
			description = strings.ReplaceAll(description, "\n", "<br>")
 | 
								description = strings.ReplaceAll(description, "\n", "<br>")
 | 
				
			||||||
| 
						 | 
					@ -155,7 +154,7 @@ func parseAlbum(data gjson.Result) (Album, error) {
 | 
				
			||||||
		album.User = User{
 | 
							album.User = User{
 | 
				
			||||||
			Id:       account.Get("id").Int(),
 | 
								Id:       account.Get("id").Int(),
 | 
				
			||||||
			Username: account.Get("username").String(),
 | 
								Username: account.Get("username").String(),
 | 
				
			||||||
			Avatar:   strings.ReplaceAll(account.Get("avatar_url").String(), "https://i.imgur.com", ""),
 | 
								Avatar:   account.Get("avatar_url").String(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,7 +57,7 @@ func (client *Client) Search(query string, page string) ([]SearchResult, error)
 | 
				
			||||||
		result := SearchResult{
 | 
							result := SearchResult{
 | 
				
			||||||
			Id: strings.Split(url, "/")[2],
 | 
								Id: strings.Split(url, "/")[2],
 | 
				
			||||||
			Url: url,
 | 
								Url: url,
 | 
				
			||||||
			ImageUrl: strings.ReplaceAll(imageUrl, "//i.imgur.com", ""),
 | 
								ImageUrl: imageUrl,
 | 
				
			||||||
			Title: s.Find(".search-item-title a").Text(),
 | 
								Title: s.Find(".search-item-title a").Text(),
 | 
				
			||||||
			User: s.Find(".account").Text(),
 | 
								User: s.Find(".account").Text(),
 | 
				
			||||||
			Views: views,
 | 
								Views: views,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,7 +82,7 @@ func (client *Client) FetchTag(tag string, sort string, page string) (Tag, error
 | 
				
			||||||
				Cover: Media{
 | 
									Cover: Media{
 | 
				
			||||||
					Id:   value.Get("cover_id").String(),
 | 
										Id:   value.Get("cover_id").String(),
 | 
				
			||||||
					Type: value.Get("cover.type").String(),
 | 
										Type: value.Get("cover.type").String(),
 | 
				
			||||||
					Url:  strings.ReplaceAll(value.Get("cover.url").String(), "https://i.imgur.com", ""),
 | 
										Url:  value.Get("cover.url").String(),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				Points:    value.Get("point_count").Int(),
 | 
									Points:    value.Get("point_count").Int(),
 | 
				
			||||||
				Upvotes:   value.Get("upvote_count").Int(),
 | 
									Upvotes:   value.Get("upvote_count").Int(),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -85,7 +85,7 @@ func (client *Client) FetchTrending(section, sort, page string) ([]Submission, e
 | 
				
			||||||
					Cover: Media{
 | 
										Cover: Media{
 | 
				
			||||||
						Id:   value.Get("cover_id").String(),
 | 
											Id:   value.Get("cover_id").String(),
 | 
				
			||||||
						Type: value.Get("cover.type").String(),
 | 
											Type: value.Get("cover.type").String(),
 | 
				
			||||||
						Url:  strings.ReplaceAll(value.Get("cover.url").String(), "https://i.imgur.com", ""),
 | 
											Url:  value.Get("cover.url").String(),
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
					Points:    value.Get("point_count").Int(),
 | 
										Points:    value.Get("point_count").Int(),
 | 
				
			||||||
					Upvotes:   value.Get("upvote_count").Int(),
 | 
										Upvotes:   value.Get("upvote_count").Int(),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,7 +61,7 @@ func (client *Client) FetchUser(username string) (User, error) {
 | 
				
			||||||
		Username:  data.Get("username").String(),
 | 
							Username:  data.Get("username").String(),
 | 
				
			||||||
		Points:    data.Get("reputation_count").Int(),
 | 
							Points:    data.Get("reputation_count").Int(),
 | 
				
			||||||
		Cover:     strings.ReplaceAll(data.Get("cover_url").String(), "https://imgur.com", ""),
 | 
							Cover:     strings.ReplaceAll(data.Get("cover_url").String(), "https://imgur.com", ""),
 | 
				
			||||||
		Avatar:    strings.ReplaceAll(data.Get("avatar_url").String(), "https://i.imgur.com", ""),
 | 
							Avatar:    data.Get("avatar_url").String(),
 | 
				
			||||||
		CreatedAt: createdTime.Format("January 2, 2006"),
 | 
							CreatedAt: createdTime.Format("January 2, 2006"),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -205,13 +205,13 @@ func parseSubmission(value gjson.Result) Submission {
 | 
				
			||||||
			Id:          coverData.Get("id").String(),
 | 
								Id:          coverData.Get("id").String(),
 | 
				
			||||||
			Description: coverData.Get("description").String(),
 | 
								Description: coverData.Get("description").String(),
 | 
				
			||||||
			Type:        strings.Split(coverData.Get("type").String(), "/")[0],
 | 
								Type:        strings.Split(coverData.Get("type").String(), "/")[0],
 | 
				
			||||||
			Url:         strings.ReplaceAll(coverData.Get("link").String(), "https://i.imgur.com", ""),
 | 
								Url:         coverData.Get("link").String(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	// This case is when fetching comments
 | 
						// This case is when fetching comments
 | 
				
			||||||
	case c.Type != gjson.Null:
 | 
						case c.Type != gjson.Null:
 | 
				
			||||||
		cover = Media{
 | 
							cover = Media{
 | 
				
			||||||
			Id:  c.Get("id").String(),
 | 
								Id:  c.Get("id").String(),
 | 
				
			||||||
			Url: strings.ReplaceAll(c.Get("url").String(), "https://i.imgur.com", ""),
 | 
								Url: c.Get("url").String(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Replace with thumbnails here because it's easier.
 | 
							// Replace with thumbnails here because it's easier.
 | 
				
			||||||
		if strings.HasSuffix(cover.Url, ".mp4") {
 | 
							if strings.HasSuffix(cover.Url, ".mp4") {
 | 
				
			||||||
| 
						 | 
					@ -222,7 +222,7 @@ func parseSubmission(value gjson.Result) Submission {
 | 
				
			||||||
			Id:          value.Get("id").String(),
 | 
								Id:          value.Get("id").String(),
 | 
				
			||||||
			Description: value.Get("description").String(),
 | 
								Description: value.Get("description").String(),
 | 
				
			||||||
			Type:        strings.Split(value.Get("type").String(), "/")[0],
 | 
								Type:        strings.Split(value.Get("type").String(), "/")[0],
 | 
				
			||||||
			Url:         strings.ReplaceAll(value.Get("link").String(), "https://i.imgur.com", ""),
 | 
								Url:         value.Get("link").String(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ import (
 | 
				
			||||||
func HandleEmbed(c *fiber.Ctx) error {
 | 
					func HandleEmbed(c *fiber.Ctx) error {
 | 
				
			||||||
	utils.SetHeaders(c)
 | 
						utils.SetHeaders(c)
 | 
				
			||||||
	c.Set("Cache-Control", "public,max-age=31557600")
 | 
						c.Set("Cache-Control", "public,max-age=31557600")
 | 
				
			||||||
	c.Set("Content-Security-Policy", "default-src 'none'; base-uri 'none'; form-action 'none'; media-src 'self'; style-src 'self'; img-src 'self'; block-all-mixed-content")
 | 
						c.Set("Content-Security-Policy", "default-src 'none'; base-uri 'none'; form-action 'none'; media-src 'self' https://i.imgur.com https://i.stack.imgur.com; style-src 'self'; img-src 'self' https://i.imgur.com https://i.stack.imgur.com; block-all-mixed-content")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	post, err := api.Album{}, error(nil)
 | 
						post, err := api.Album{}, error(nil)
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@ func HandlePost(c *fiber.Ctx) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.Set("Cache-Control", "public,max-age=31557600")
 | 
						c.Set("Cache-Control", "public,max-age=31557600")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	csp := "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; media-src 'self'; img-src 'self'; manifest-src 'self'; block-all-mixed-content; style-src 'self'"
 | 
						csp := "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; media-src 'self' https://i.imgur.com https://i.stack.imgur.com; img-src 'self' https://i.imgur.com https://i.stack.imgur.com; manifest-src 'self'; block-all-mixed-content; style-src 'self'"
 | 
				
			||||||
	c.Set("Content-Security-Policy", csp)
 | 
						c.Set("Content-Security-Policy", csp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var next string
 | 
						var next string
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ func HandleSearch(c *fiber.Ctx) error {
 | 
				
			||||||
	utils.SetHeaders(c)
 | 
						utils.SetHeaders(c)
 | 
				
			||||||
	c.Set("X-Frame-Options", "DENY")
 | 
						c.Set("X-Frame-Options", "DENY")
 | 
				
			||||||
	c.Set("Cache-Control", "public,max-age=604800")
 | 
						c.Set("Cache-Control", "public,max-age=604800")
 | 
				
			||||||
	c.Set("Content-Security-Policy", "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; style-src 'unsafe-inline' 'self'; media-src 'self'; img-src 'self'; manifest-src 'self'; block-all-mixed-content")
 | 
						c.Set("Content-Security-Policy", "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; style-src 'unsafe-inline' 'self'; media-src 'self' https://i.imgur.com https://i.stack.imgur.com; img-src 'self' https://i.imgur.com https://i.stack.imgur.com; manifest-src 'self'; block-all-mixed-content")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	query := c.Query("q")
 | 
						query := c.Query("q")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ func HandleTag(c *fiber.Ctx) error {
 | 
				
			||||||
	utils.SetHeaders(c)
 | 
						utils.SetHeaders(c)
 | 
				
			||||||
	c.Set("X-Frame-Options", "DENY")
 | 
						c.Set("X-Frame-Options", "DENY")
 | 
				
			||||||
	c.Set("Cache-Control", "public,max-age=604800")
 | 
						c.Set("Cache-Control", "public,max-age=604800")
 | 
				
			||||||
	c.Set("Content-Security-Policy", "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; style-src 'unsafe-inline' 'self'; media-src 'self'; img-src 'self'; manifest-src 'self'; block-all-mixed-content")
 | 
						c.Set("Content-Security-Policy", "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; style-src 'unsafe-inline' 'self'; media-src 'self' https://i.imgur.com https://i.stack.imgur.com; img-src 'self' https://i.imgur.com https://i.stack.imgur.com; manifest-src 'self'; block-all-mixed-content")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	page := "1"
 | 
						page := "1"
 | 
				
			||||||
	if c.Query("page") != "" {
 | 
						if c.Query("page") != "" {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ func HandleTrending(c *fiber.Ctx) error {
 | 
				
			||||||
	utils.SetHeaders(c)
 | 
						utils.SetHeaders(c)
 | 
				
			||||||
	c.Set("X-Frame-Options", "DENY")
 | 
						c.Set("X-Frame-Options", "DENY")
 | 
				
			||||||
	c.Set("Cache-Control", "public,max-age=604800")
 | 
						c.Set("Cache-Control", "public,max-age=604800")
 | 
				
			||||||
	c.Set("Content-Security-Policy", "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; style-src 'unsafe-inline' 'self'; media-src 'self'; img-src 'self'; manifest-src 'self'; block-all-mixed-content")
 | 
						c.Set("Content-Security-Policy", "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; style-src 'unsafe-inline' 'self'; media-src 'self' https://i.imgur.com https://i.stack.imgur.com; img-src 'self' https://i.imgur.com https://i.stack.imgur.com; manifest-src 'self'; block-all-mixed-content")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	page := "1"
 | 
						page := "1"
 | 
				
			||||||
	if c.Query("page") != "" {
 | 
						if c.Query("page") != "" {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ func HandleUser(c *fiber.Ctx) error {
 | 
				
			||||||
	utils.SetHeaders(c)
 | 
						utils.SetHeaders(c)
 | 
				
			||||||
	c.Set("X-Frame-Options", "DENY")
 | 
						c.Set("X-Frame-Options", "DENY")
 | 
				
			||||||
	c.Set("Cache-Control", "public,max-age=604800")
 | 
						c.Set("Cache-Control", "public,max-age=604800")
 | 
				
			||||||
	c.Set("Content-Security-Policy", "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; media-src 'self'; style-src 'unsafe-inline' 'self'; img-src 'self'; manifest-src 'self'; block-all-mixed-content")
 | 
						c.Set("Content-Security-Policy", "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; media-src 'self' https://i.imgur.com https://i.stack.imgur.com; style-src 'unsafe-inline' 'self'; img-src 'self' https://i.imgur.com https://i.stack.imgur.com; manifest-src 'self'; block-all-mixed-content")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	page := "0"
 | 
						page := "0"
 | 
				
			||||||
	if c.Query("page") != "" {
 | 
						if c.Query("page") != "" {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue