Skip to content

Commit 3449b00

Browse files
authored
Merge pull request #3 from MagnusIIIBR/Dev
Gerador de Albums
2 parents f1f31ca + e38ba1d commit 3449b00

10 files changed

Lines changed: 204 additions & 26 deletions

.vs/GeradorBBCode/v16/.suo

10 KB
Binary file not shown.

.vs/VSWorkspaceState.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ExpandedNodes": [
3+
""
4+
],
5+
"PreviewInSolutionExplorer": false
6+
}

.vs/slnx.sqlite

104 KB
Binary file not shown.

index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ <h2 class="subtitle">
3939
<option value="1">Filmes/Séries/Episódios (IMDb)</option>
4040
<option value="2">Jogos de PC (STEAM)</option>
4141
<option value="3">Aplicativo Android (Play Store)</option>
42+
<option value="4">Álbum de música (LastFM)</option>
4243
</select>
4344
</div>
4445
</div>
@@ -101,6 +102,25 @@ <h2 class="subtitle">
101102
</div>
102103
</div>
103104

105+
<div class="box" id="divLastFM" style="display:none">
106+
<div class="field has-addons">
107+
<div class="control is-expanded">
108+
<div class=" is-fullwidth">
109+
<div class="field">
110+
<div class="control">
111+
<input class="input is-primary" id="txtLastFMUrl" type="text"
112+
placeholder="Exemplo: https://www.last.fm/pt/music/Alan Walker/Different World">
113+
</div>
114+
</div>
115+
116+
</div>
117+
</div>
118+
<div class="control">
119+
<button type="button" id="btnLoadLastFM" class="button is-primary">Escolher</button>
120+
</div>
121+
</div>
122+
</div>
123+
104124
<div class="box" id="divGenerico" style="display: none;">
105125
<div class="field">
106126
<div class="control is-expanded">
@@ -202,6 +222,7 @@ <h2 class="subtitle">
202222
<script type="text/javascript" src="js/geradorFilmeSerieEpisodio.js"></script>
203223
<script type="text/javascript" src="js/geradorJogosSteam.js"></script>
204224
<script type="text/javascript" src="js/geradorAplicativoPlayStore.js"></script>
225+
<script type="text/javascript" src="js/geradorAlbumLastFM.js"></script>
205226
<script type="text/javascript" src="js/geradorGenerico.js"></script>
206227
<script type="text/javascript" src="js/indexView.js"></script>
207228
<script type="text/javascript">

js/baseLib.js

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ var baseLib = {
1818
urlLogoRottenTomatoesImage: "https://i.postimg.cc/rppL76qC/rotten.png",
1919
urlLogoGooglePlayStoreImage: "https://i.postimg.cc/pLRvYh7S/google.png",
2020

21-
urlBaseTMDbPoster: "https://image.tmdb.org/t/p/w600_and_h900_bestv2/"
21+
urlBaseTMDbPoster: "https://image.tmdb.org/t/p/w600_and_h900_bestv2",
22+
23+
urlServiceSteam: "https://staging.vindicator.com.br/steam?id=",
24+
urlServiceOMDb: "https://www.omdbapi.com/?i=",
25+
urlServiceTMDb: "https://api.themoviedb.org/3/find/",
26+
urlServicePlayStore: "https://staging.vindicator.com.br/googleplay?id=",
27+
urlServiceLastFM: "https://staging.vindicator.com.br/lastfm?id=",
2228
},
2329

2430
copyToClipboard: function (str) {
@@ -57,20 +63,20 @@ var baseLib = {
5763
}
5864
},
5965

60-
parseHtmlToBBCode: function(html){
61-
66+
parseHtmlToBBCode: function (html) {
67+
6268
html = html.replace(/<pre(.*?)>(.*?)<\/pre>/gmi, "$2");
6369

6470
html = html.replace(/<h[1-7](.*?)>(.*?)<\/h[1-7]>/, "\n$2\n");
65-
71+
6672
//paragraph handling:
6773
//- if a paragraph opens on the same line as another one closes, insert an extra blank line
6874
//- opening tag becomes two line breaks
6975
//- closing tags are just removed
7076
// html += html.replace(/<\/p><p/<\/p>\n<p/gi;
7177
// html += html.replace(/<p[^>]*>/\n\n/gi;
7278
// html += html.replace(/<\/p>//gi;
73-
79+
7480
html = html.replace(/<br(.*?)>/gi, "\n");
7581
html = html.replace(/<textarea(.*?)>(.*?)<\/textarea>/gmi, "\$2");
7682
html = html.replace(/<b>/gi, "[b]");
@@ -95,30 +101,50 @@ var baseLib = {
95101
html = html.replace(/<\/div>/gi, "\n");
96102
html = html.replace(/<td(.*?)>/gi, " ");
97103
html = html.replace(/<tr(.*?)>/gi, "\n");
98-
104+
99105
html = html.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, "[img]$2[/img]");
100106
html = html.replace(/<a(.*?)href="(.*?)"(.*?)>(.*?)<\/a>/gi, "[url=$2]$4[/url]");
101-
107+
102108
html = html.replace(/<head>(.*?)<\/head>/gmi, "");
103109
html = html.replace(/<object>(.*?)<\/object>/gmi, "");
104110
html = html.replace(/<script(.*?)>(.*?)<\/script>/gmi, "");
105111
html = html.replace(/<style(.*?)>(.*?)<\/style>/gmi, "");
106112
html = html.replace(/<title>(.*?)<\/title>/gmi, "");
107113
html = html.replace(/<!--(.*?)-->/gmi, "\n");
108-
114+
109115
html = html.replace(/\/\//gi, "/");
110116
html = html.replace(/http:\//gi, "http://");
111-
117+
112118
html = html.replace(/<(?:[^>'"]*|(['"]).*?\1)*>/gmi, "");
113-
html = html.replace(/\r\r/gi, "");
119+
html = html.replace(/\r\r/gi, "");
114120
html = html.replace(/\[img]\//gi, "[img]");
115121
html = html.replace(/\[url=\//gi, "[url=");
116-
122+
117123
html = html.replace(/(\S)\n/gi, "$1 ");
118-
124+
119125
return html;
126+
},
127+
128+
//https://stackoverflow.com/questions/3733227/javascript-seconds-to-minutes-and-seconds
129+
fancyTimeFormat: function (time) {
130+
// Hours, minutes and seconds
131+
var hrs = ~~(time / 3600);
132+
var mins = ~~((time % 3600) / 60);
133+
var secs = ~~time % 60;
134+
135+
// Output like "1:01" or "4:03:59" or "123:03:59"
136+
var ret = "";
137+
138+
if (hrs > 0) {
139+
ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
140+
}
141+
142+
ret += "" + mins + ":" + (secs < 10 ? "0" : "");
143+
ret += "" + secs;
144+
return ret;
120145
}
121146

122147

123148

149+
124150
};

js/geradorAlbumLastFM.js

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
var geradorAlbumLastFM = {
2+
3+
urlLastFM: null,
4+
5+
Data: {
6+
LastFM: null
7+
},
8+
9+
Validar: function () {
10+
11+
try {
12+
baseLib.showLoading(true);
13+
14+
var lastfmBaseUrl = ["https://www.last.fm/pt/music/", "https://www.last.fm/en/music/"];
15+
16+
if (this.urlLastFM.trim().length == 0 || this.urlLastFM == null) {
17+
throw new Error("A URL do álbum no LastFM é obrigatória!");
18+
}
19+
20+
this.Data.LastFM = this.LastFMService(this.urlLastFM.trim());
21+
console.log(this.Data.LastFM);
22+
23+
if (this.Data.LastFM.error != undefined) {
24+
throw new Error("Erro: " + this.Data.LastFM.message);
25+
}
26+
27+
baseLib.copyToClipboard(this.GerarBBCode());
28+
bulmaToast.toast({
29+
message: "BBCode copiado para a área de transferência!",
30+
type: "is-success",
31+
duration: 4000
32+
});
33+
} catch (error) {
34+
bulmaToast.toast({
35+
message: error.message,
36+
type: "is-danger",
37+
duration: 4000
38+
});
39+
} finally {
40+
baseLib.showLoading(false);
41+
}
42+
43+
},
44+
45+
GerarBBCode: function () {
46+
var str = `
47+
${this.InserirTitulo()}
48+
${this.InserirCapa()}
49+
${this.InserirInformacao()}
50+
${this.InserirFaixas()}
51+
`;
52+
53+
return str;
54+
55+
},
56+
57+
InserirTitulo: function () {
58+
var str = ` [align=center][img]${baseLib.StaticUrl.urlSeparadorApresentaImage}[/img][/align]
59+
[b][align=center] ${this.Data.LastFM.album.name} [/align][/b]
60+
[b][align=center] ${this.Data.LastFM.album.artist} [/align][/b]`;
61+
62+
return str;
63+
},
64+
65+
InserirCapa: function () {
66+
var selectedCapa = this.Data.LastFM.album.image[3];
67+
if(selectedCapa == null || selectedCapa == undefined) selectedCapa = this.Data.LastFM.album.image[2];
68+
69+
return `[align=center][img]${baseLib.StaticUrl.urlSeparadorCapaImage}[/img][/align]
70+
[align=center][img]${selectedCapa['#text']}[/img][/align]`;
71+
},
72+
73+
InserirInformacao: function () {
74+
var str = "";
75+
str += `\n[align=center][img]${baseLib.StaticUrl.urlSeparadorFichaTecnicaImage}[/img][/align]`;
76+
if (this.Data.LastFM.album.release_date != undefined) str += `\n[align=center]Data de Lançamento: ${this.Data.LastFM.data.release_date.date} [/align]`;
77+
str += `\n[align=center]Ouvintes (LastFM): ${this.Data.LastFM.album.listeners } [/align]`;
78+
str += `\n[align=center]Contagem de plays (LastFM): ${this.Data.LastFM.album.playcount} [/align]`;
79+
if (this.Data.LastFM.album.wiki != undefined) if (this.Data.LastFM.album.wiki.published != undefined) str += `\n[align=center]Publicação: ${this.Data.LastFM.album.wiki.published} [/align]`;
80+
if (this.Data.LastFM.album.url != null) str += `\n[align=center]Site: [url=${this.Data.LastFM.album.url}] Clique aqui [/url][/align]`;
81+
82+
83+
return str;
84+
},
85+
86+
InserirFaixas: function () {
87+
var str = "";
88+
// str += `\n[align=center][img]${baseLib.StaticUrl.urlSeparadorRequisitosmage}[/img][/align]`;
89+
90+
var nroFaixa = 1;
91+
this.Data.LastFM.album.tracks.track.forEach(element => {
92+
str += `\n[align=center][b]${nroFaixa}[/b] - ${element.name} (${baseLib.fancyTimeFormat(element.duration)})[/align]`;
93+
nroFaixa++;
94+
});
95+
96+
// str += `\n[align=center]Ouvintes: ${this.Data.LastFM.data.genres.map(function (elem) { return elem.description; }).join(", ")} [/align]`;
97+
// str += `\n[align=center]Desenvolvedores: ${this.Data.LastFM.data.developers.join(", ")} [/align]`;
98+
99+
return str;
100+
},
101+
102+
InserirAgradecaComente: function () {
103+
104+
},
105+
106+
LastFMService: function () {
107+
var urlRequest = baseLib.StaticUrl.urlServiceLastFM + this.urlLastFM;
108+
109+
var result = null;
110+
111+
$.ajax({
112+
url: urlRequest,
113+
async: false,
114+
success: function (data) {
115+
result = data;
116+
}
117+
});
118+
return result;
119+
},
120+
};

js/geradorAplicativoPlayStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ var GeradorAplicativoPlayStore = {
108108

109109

110110
GooglePlayService: function () {
111-
var urlRequest = "https://vindicator.com.br/services/googleplay?id=" + this.GooglePlayId;
111+
var urlRequest = baseLib.StaticUrl.urlServicePlayStore + this.GooglePlayId;
112112

113113
var result = null;
114114

js/geradorFilmeSerieEpisodio.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ var GeradorFilmeSerieEpisodio = {
226226

227227

228228
OMDbService: function () {
229-
var urlRequest = "https://www.omdbapi.com/?i=" + this.IMDbId + "&y=&plot=full&apikey=b045eb33";
229+
var urlRequest = baseLib.StaticUrl.urlServiceOMDb + this.IMDbId + "&y=&plot=full&apikey=b045eb33";
230230

231231
var result = null;
232232

@@ -241,7 +241,7 @@ var GeradorFilmeSerieEpisodio = {
241241
},
242242

243243
TMDbService: function () {
244-
var urlRequest = "https://api.themoviedb.org/3/find/" + this.IMDbId + "?api_key=650fbb9313eab50f47bc5981772e8218&language=pt-BR&external_source=imdb_id";
244+
var urlRequest = baseLib.StaticUrl.urlServiceTMDb + this.IMDbId + "?api_key=650fbb9313eab50f47bc5981772e8218&language=pt-BR&external_source=imdb_id";
245245

246246
var result = null;
247247

js/geradorJogosSteam.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ var GeradorJogosSteam = {
153153
},
154154

155155
SteamService: function () {
156-
var urlRequest = "https://vindicator.com.br/services/steam?id=" + this.SteamId;
156+
var urlRequest = baseLib.StaticUrl.urlServiceSteam + this.SteamId;
157157

158158
var result = null;
159159

js/indexView.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ var indexView = {
1717
case "3":
1818
$('#divPlayStore').show();
1919
break;
20+
case "4":
21+
$('#divLastFM').show();
22+
break;
2023
default:
2124
break;
2225
}
@@ -27,21 +30,23 @@ var indexView = {
2730

2831
GeradorFilmeSerieEpisodio.IMDbId = $('#txtIMDbId').val().trim();
2932
GeradorFilmeSerieEpisodio.Validar();
30-
3133
});
3234

3335
$('#btnLoadSteam').click(function () {
3436

3537
GeradorJogosSteam.SteamId = $('#txtSteamId').val().trim();
3638
GeradorJogosSteam.Validar();
37-
3839
});
3940

4041
$('#btnLoadPlayStore').click(function () {
4142

4243
GeradorAplicativoPlayStore.GooglePlayId = $('#txtPlayStoreId').val().trim();
4344
GeradorAplicativoPlayStore.Validar();
45+
});
4446

47+
$('#btnLoadLastFM').click(function () {
48+
geradorAlbumLastFM.urlLastFM = $('#txtLastFMUrl').val().trim();
49+
geradorAlbumLastFM.Validar();
4550
});
4651

4752
$(document)
@@ -52,15 +57,15 @@ var indexView = {
5257
$('#pageLoader').removeClass("is-active");
5358
});
5459

55-
$('.tooltip').tooltipster({
56-
theme: 'tooltipster-shadow',
57-
animation: 'fade',
58-
delay: 100,
59-
trigger: 'click',
60-
side: ['right']
60+
$('.tooltip').tooltipster({
61+
theme: 'tooltipster-shadow',
62+
animation: 'fade',
63+
delay: 100,
64+
trigger: 'click',
65+
side: ['right']
6166

62-
63-
});
67+
68+
});
6469

6570

6671

0 commit comments

Comments
 (0)