structs in structs
This commit is contained in:
		
							parent
							
								
									a61f3468ee
								
							
						
					
					
						commit
						e4586cd5f3
					
				
							
								
								
									
										86
									
								
								structs.go
								
								
								
								
							
							
						
						
									
										86
									
								
								structs.go
								
								
								
								
							|  | @ -16,23 +16,11 @@ type TokenResponse struct { | ||||||
| 	ExpiresIn   int64  `json:"expires_in"` | 	ExpiresIn   int64  `json:"expires_in"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type RedditVideo struct { | type GalleryData struct { | ||||||
| 	HlsUrl      string `json:"hls_url"` | 	Items []struct { | ||||||
| 	DashUrl     string `json:"dash_url"` |  | ||||||
| 	FallbackUrl string `json:"fallback_url"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type SecureMedia struct { |  | ||||||
| 	RedditVideo *RedditVideo `json:"reddit_video"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type GalleryDataItem struct { |  | ||||||
| 		Id      int    `json:"id"` | 		Id      int    `json:"id"` | ||||||
| 		MediaId string `json:"media_id"` | 		MediaId string `json:"media_id"` | ||||||
| } | 	} `json:"items"` | ||||||
| 
 |  | ||||||
| type GalleryData struct { |  | ||||||
| 	Items []GalleryDataItem `json:"items"` |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (s GalleryData) Len() int { | func (s GalleryData) Len() int { | ||||||
|  | @ -45,61 +33,51 @@ func (s GalleryData) Less(i, j int) bool { | ||||||
| 	return s.Items[i].Id < s.Items[j].Id | 	return s.Items[i].Id < s.Items[j].Id | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // despite the name, it is not several items, but one
 |  | ||||||
| // ???
 |  | ||||||
| type MediaMetadataItemS struct { |  | ||||||
| 	U   string `json:"u"` |  | ||||||
| 	Mp4 string `json:"mp4"` |  | ||||||
| 	Gif string `json:"gif"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type MediaMetadataItem struct { |  | ||||||
| 	Status string              `json:"status"` |  | ||||||
| 	S      *MediaMetadataItemS `json:"s"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type PreviewSource struct { | type PreviewSource struct { | ||||||
| 	Url string `json:"url"` | 	Url string `json:"url"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type PreviewVariants struct { |  | ||||||
| 	Mp4 *PreviewSource `json:"mp4"` |  | ||||||
| 	Gif *PreviewSource `json:"gif"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type PreviewImage struct { |  | ||||||
| 	Variants *PreviewVariants `json:"variants"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type Preview struct { |  | ||||||
| 	Images []PreviewImage `json:"images"` |  | ||||||
| 	Source *PreviewSource `json:"source"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type Submission struct { | type Submission struct { | ||||||
| 	CrosspostParent string `json:"crosspost_parent"` | 	CrosspostParent string `json:"crosspost_parent"` | ||||||
| 	// we don't care about the list, just does it exist or not
 | 	// we don't care about the list, just does it exist or not
 | ||||||
| 	CrosspostParentList []interface{} `json:"crosspost_parent_list"` | 	CrosspostParentList []interface{} `json:"crosspost_parent_list"` | ||||||
| 	Url                 string        `json:"url"` | 	Url                 string        `json:"url"` | ||||||
| 	IsVideo             bool          `json:"is_video"` | 	IsVideo             bool          `json:"is_video"` | ||||||
| 	SecureMedia         *SecureMedia                 `json:"secure_media"` | 	SecureMedia         struct { | ||||||
|  | 		RedditVideo struct { | ||||||
|  | 			HlsUrl      string `json:"hls_url"` | ||||||
|  | 			DashUrl     string `json:"dash_url"` | ||||||
|  | 			FallbackUrl string `json:"fallback_url"` | ||||||
|  | 		} `json:"reddit_video"` | ||||||
|  | 	} `json:"secure_media"` | ||||||
| 	IsGallery     bool         `json:"is_gallery"` | 	IsGallery     bool         `json:"is_gallery"` | ||||||
| 	GalleryData   *GalleryData `json:"gallery_data"` | 	GalleryData   *GalleryData `json:"gallery_data"` | ||||||
| 	MediaMetadata       map[string]MediaMetadataItem `json:"media_metadata"` | 	MediaMetadata map[string]struct { | ||||||
|  | 		Status string `json:"status"` | ||||||
|  | 		S      struct { | ||||||
|  | 			U   string `json:"u"` | ||||||
|  | 			Mp4 string `json:"mp4"` | ||||||
|  | 			Gif string `json:"gif"` | ||||||
|  | 		} `json:"s"` | ||||||
|  | 	} `json:"media_metadata"` | ||||||
| 	IsRedditMediaDomain bool `json:"is_reddit_media_domain"` | 	IsRedditMediaDomain bool `json:"is_reddit_media_domain"` | ||||||
| 	Preview             *Preview                     `json:"preview"` | 	Preview             struct { | ||||||
|  | 		Images []struct { | ||||||
|  | 			Variants struct { | ||||||
|  | 				Mp4 *PreviewSource `json:"mp4"` | ||||||
|  | 				Gif *PreviewSource `json:"gif"` | ||||||
|  | 			} `json:"variants"` | ||||||
|  | 		} `json:"images"` | ||||||
|  | 		Source *PreviewSource `json:"source"` | ||||||
|  | 	} `json:"preview"` | ||||||
| 	IsSelf bool   `json:"is_self"` | 	IsSelf bool   `json:"is_self"` | ||||||
| 	Title  string `json:"title"` | 	Title  string `json:"title"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type SubmissionChild struct { |  | ||||||
| 	Data *Submission `json:"data"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type SubmissionResponseItemData struct { |  | ||||||
| 	Children []SubmissionChild `json:"children"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type SubmissionResponseItem struct { | type SubmissionResponseItem struct { | ||||||
| 	Data SubmissionResponseItemData `json:"data"` | 	Data struct { | ||||||
|  | 		Children []struct { | ||||||
|  | 			Data *Submission `json:"data"` | ||||||
|  | 		} `json:"children"` | ||||||
|  | 	} `json:"data"` | ||||||
| } | } | ||||||
|  |  | ||||||
		Reference in New Issue