Skip to content

Commit 906701f

Browse files
committed
feat: encapsulate internal packages
1 parent 5ef12cc commit 906701f

30 files changed

+65
-52
lines changed

helpers/get_album_browse_id.go renamed to internal/helpers/get_album_browse_id.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"regexp"
77
"strings"
88

9-
"github.com/ghoshRitesh12/brooktube/utils"
9+
"github.com/ghoshRitesh12/brooktube/internal/utils"
1010
)
1111

1212
const RAW_ALBUM_ID_PREFIX string = "OLAK5"

helpers/parse_artist_song_contents.go renamed to internal/helpers/parse_artist_song_contents.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package helpers
22

33
import (
4-
"github.com/ghoshRitesh12/brooktube/models/search"
5-
"github.com/ghoshRitesh12/brooktube/utils"
4+
"github.com/ghoshRitesh12/brooktube/internal/models/search"
5+
"github.com/ghoshRitesh12/brooktube/internal/utils"
66
)
77

88
func ParseArtistSongContents(shelfContents *[]search.APIRespSectionContent) []search.SongOrVideo {

helpers/parse_search_content.go renamed to internal/helpers/parse_search_content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package helpers
22

33
import (
4-
"github.com/ghoshRitesh12/brooktube/models/search"
4+
"github.com/ghoshRitesh12/brooktube/internal/models/search"
55
)
66

77
func ParseSearchContent(category search.SearchCategory, shelfContents []search.APIRespSectionContent) search.ResultContent {

models/album/api_response.go renamed to internal/models/album/api_response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package album
22

33
import (
4-
"github.com/ghoshRitesh12/brooktube/models"
5-
"github.com/ghoshRitesh12/brooktube/models/search"
4+
"github.com/ghoshRitesh12/brooktube/internal/models"
5+
"github.com/ghoshRitesh12/brooktube/internal/models/search"
66
)
77

88
type APIResp struct {

models/album/response.go renamed to internal/models/album/response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"strings"
66
"sync"
77

8-
"github.com/ghoshRitesh12/brooktube/models"
9-
"github.com/ghoshRitesh12/brooktube/utils"
8+
"github.com/ghoshRitesh12/brooktube/internal/models"
9+
"github.com/ghoshRitesh12/brooktube/internal/utils"
1010
)
1111

1212
type ScrapedData struct {

models/artist/api_response.go renamed to internal/models/artist/api_response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package artist
22

33
import (
4-
"github.com/ghoshRitesh12/brooktube/models"
5-
"github.com/ghoshRitesh12/brooktube/models/search"
4+
"github.com/ghoshRitesh12/brooktube/internal/models"
5+
"github.com/ghoshRitesh12/brooktube/internal/models/search"
66
)
77

88
type APIResp struct {

models/artist/response.go renamed to internal/models/artist/response.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"strings"
55
"sync"
66

7-
"github.com/ghoshRitesh12/brooktube/helpers"
8-
"github.com/ghoshRitesh12/brooktube/models/search"
9-
"github.com/ghoshRitesh12/brooktube/utils"
7+
"github.com/ghoshRitesh12/brooktube/internal/helpers"
8+
"github.com/ghoshRitesh12/brooktube/internal/models/search"
9+
"github.com/ghoshRitesh12/brooktube/internal/utils"
1010
)
1111

1212
type ScrapedData struct {
File renamed without changes.

models/common.go renamed to internal/models/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package models
22

3-
import "github.com/ghoshRitesh12/brooktube/utils"
3+
import "github.com/ghoshRitesh12/brooktube/internal/utils"
44

55
type Continuations []struct {
66
NextContinuationData struct {
File renamed without changes.

models/playlist/api_response.go renamed to internal/models/playlist/api_response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package playlist
22

33
import (
4-
"github.com/ghoshRitesh12/brooktube/models"
5-
"github.com/ghoshRitesh12/brooktube/models/search"
4+
"github.com/ghoshRitesh12/brooktube/internal/models"
5+
"github.com/ghoshRitesh12/brooktube/internal/models/search"
66
)
77

88
type APIResp struct {

models/playlist/response.go renamed to internal/models/playlist/response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"strings"
55
"sync"
66

7-
"github.com/ghoshRitesh12/brooktube/models"
8-
"github.com/ghoshRitesh12/brooktube/utils"
7+
"github.com/ghoshRitesh12/brooktube/internal/models"
8+
"github.com/ghoshRitesh12/brooktube/internal/utils"
99
)
1010

1111
type ScrapedData struct {

models/search/api_response.go renamed to internal/models/search/api_response.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package search
22

3-
import "github.com/ghoshRitesh12/brooktube/models"
3+
import "github.com/ghoshRitesh12/brooktube/internal/models"
44

55
type APIResp struct {
66
Contents struct {

models/search/response.go renamed to internal/models/search/response.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package search
33
import (
44
"strings"
55

6-
"github.com/ghoshRitesh12/brooktube/utils"
6+
"github.com/ghoshRitesh12/brooktube/internal/utils"
77
)
88

99
type ScrapedData struct {
File renamed without changes.

requests/album.go renamed to internal/requests/album.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package requests
33
import (
44
"net/url"
55

6-
"github.com/ghoshRitesh12/brooktube/helpers"
7-
"github.com/ghoshRitesh12/brooktube/models/album"
8-
"github.com/ghoshRitesh12/brooktube/utils"
6+
"github.com/ghoshRitesh12/brooktube/internal/helpers"
7+
"github.com/ghoshRitesh12/brooktube/internal/models/album"
8+
"github.com/ghoshRitesh12/brooktube/internal/utils"
99
)
1010

1111
func FetchAlbum(albumBrowseId string) (*album.APIResp, error) {

requests/artist.go renamed to internal/requests/artist.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package requests
33
import (
44
"net/url"
55

6-
"github.com/ghoshRitesh12/brooktube/helpers"
7-
"github.com/ghoshRitesh12/brooktube/models/artist"
8-
"github.com/ghoshRitesh12/brooktube/utils"
6+
"github.com/ghoshRitesh12/brooktube/internal/helpers"
7+
"github.com/ghoshRitesh12/brooktube/internal/models/artist"
8+
"github.com/ghoshRitesh12/brooktube/internal/utils"
99
)
1010

1111
func FetchArtist(artistChannelID string) (*artist.APIResp, error) {

requests/main.go renamed to internal/requests/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"net/http"
88

9-
"github.com/ghoshRitesh12/brooktube/utils"
9+
"github.com/ghoshRitesh12/brooktube/internal/utils"
1010
)
1111

1212
var defaultHeaders = map[string]string{

requests/playlist.go renamed to internal/requests/playlist.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package requests
33
import (
44
"net/url"
55

6-
"github.com/ghoshRitesh12/brooktube/helpers"
7-
"github.com/ghoshRitesh12/brooktube/models/playlist"
8-
"github.com/ghoshRitesh12/brooktube/utils"
6+
"github.com/ghoshRitesh12/brooktube/internal/helpers"
7+
"github.com/ghoshRitesh12/brooktube/internal/models/playlist"
8+
"github.com/ghoshRitesh12/brooktube/internal/utils"
99
)
1010

1111
func FetchPlaylist(playlistId string) (*playlist.APIResp, error) {

requests/search.go renamed to internal/requests/search.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package requests
33
import (
44
"net/url"
55

6-
"github.com/ghoshRitesh12/brooktube/models/search"
7-
"github.com/ghoshRitesh12/brooktube/utils"
6+
"github.com/ghoshRitesh12/brooktube/internal/models/search"
7+
"github.com/ghoshRitesh12/brooktube/internal/utils"
88
)
99

1010
func FetchSearchResults(query string, category search.SearchCategory, continuationToken string) (*search.APIResp, error) {
File renamed without changes.
File renamed without changes.
File renamed without changes.

parsers/album.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"strings"
55
"sync"
66

7-
"github.com/ghoshRitesh12/brooktube/helpers"
8-
"github.com/ghoshRitesh12/brooktube/models/album"
9-
"github.com/ghoshRitesh12/brooktube/requests"
10-
"github.com/ghoshRitesh12/brooktube/utils"
7+
"github.com/ghoshRitesh12/brooktube/internal/helpers"
8+
"github.com/ghoshRitesh12/brooktube/internal/models/album"
9+
"github.com/ghoshRitesh12/brooktube/internal/requests"
10+
"github.com/ghoshRitesh12/brooktube/internal/utils"
1111
)
1212

1313
const ALBUM_SCRAPE_OPERATIONS int = 2

parsers/artist.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package parsers
33
import (
44
"sync"
55

6-
"github.com/ghoshRitesh12/brooktube/models/artist"
7-
"github.com/ghoshRitesh12/brooktube/requests"
6+
"github.com/ghoshRitesh12/brooktube/internal/models/artist"
7+
"github.com/ghoshRitesh12/brooktube/internal/requests"
88
)
99

1010
const ARTIST_SCRAPE_OPERATIONS int = 7

parsers/artist_test.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,27 @@ import (
77
"github.com/ghoshRitesh12/brooktube"
88
)
99

10+
// go test -run TestGetArtist ./parsers -v -count=1
1011
func TestGetArtist(t *testing.T) {
11-
const EMINEM_CHANNEL_ID = "UCedvOgsKFzcK3hA5taf3KoQ"
12-
brooktube := brooktube.New()
13-
14-
artist, err := brooktube.GetArtist(EMINEM_CHANNEL_ID)
15-
if err != nil {
16-
t.Error(err)
12+
testsTable := []struct {
13+
channelName string
14+
channelId string
15+
}{
16+
{"eminem", "UCedvOgsKFzcK3hA5taf3KoQ"},
17+
{"naruto playlist guy", "UClX0RWY5bWVzGrWMTTD8iIQ"},
1718
}
1819

19-
spew.Dump(artist)
20+
btube := brooktube.New()
21+
22+
for _, test := range testsTable {
23+
t.Run(test.channelName, func(t *testing.T) {
24+
25+
artist, err := btube.GetArtist(test.channelId)
26+
if err != nil {
27+
t.Error(err)
28+
}
29+
30+
spew.Dump(artist)
31+
})
32+
}
2033
}

parsers/playlist.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"strings"
55
"sync"
66

7-
"github.com/ghoshRitesh12/brooktube/models/playlist"
8-
"github.com/ghoshRitesh12/brooktube/requests"
9-
"github.com/ghoshRitesh12/brooktube/utils"
7+
"github.com/ghoshRitesh12/brooktube/internal/models/playlist"
8+
"github.com/ghoshRitesh12/brooktube/internal/requests"
9+
"github.com/ghoshRitesh12/brooktube/internal/utils"
1010
)
1111

1212
const PLAYLIST_ID_PREFIX string = "VL"

parsers/search.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package parsers
22

33
import (
4-
"github.com/ghoshRitesh12/brooktube/helpers"
5-
"github.com/ghoshRitesh12/brooktube/models/search"
6-
"github.com/ghoshRitesh12/brooktube/requests"
4+
"github.com/ghoshRitesh12/brooktube/internal/helpers"
5+
"github.com/ghoshRitesh12/brooktube/internal/models/search"
6+
"github.com/ghoshRitesh12/brooktube/internal/requests"
77
)
88

99
type SearchParserParams struct {

parsers/search_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55

66
"github.com/davecgh/go-spew/spew"
77
"github.com/ghoshRitesh12/brooktube"
8-
"github.com/ghoshRitesh12/brooktube/models/search"
8+
"github.com/ghoshRitesh12/brooktube/internal/models/search"
99
"github.com/ghoshRitesh12/brooktube/parsers"
1010
)
1111

0 commit comments

Comments
 (0)