Skip to content
Snippets Groups Projects
Commit 5204bb36 authored by ismcarb's avatar ismcarb
Browse files

Cambios y covers

parent 6e55dc19
No related branches found
No related tags found
No related merge requests found
Showing
with 354 additions and 105 deletions
...@@ -4,21 +4,17 @@ ...@@ -4,21 +4,17 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="0c5e7f40-d6e0-4cdf-8175-c288dac24af5" name="Changes" comment="Las canciones"> <list default="true" id="0c5e7f40-d6e0-4cdf-8175-c288dac24af5" name="Changes" comment="workspace">
<change afterPath="$PROJECT_DIR$/mp3files/destination/AmanteBandido.mp3" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/ContinuousReadL.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/destination/AmigaMia.mp3" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PrimerasOperaciones.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/destination/AmparitoRoca.mp3" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/SegundasOperaciones.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/destination/Quijote.mp3" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/destination/cancion.mp3" afterDir="false" /> <change beforePath="$PROJECT_DIR$/mp3files/origin/coverGwendolyne.jpeg" beforeDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/origin/AmanteBandido.mp3" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/spotify/rmi/client/CompleteMetadata.java" beforeDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/origin/AmigaMia.mp3" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlayList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlayList.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/origin/AmorDeHombre.mp3" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlaySong.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlaySong.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/origin/AmparitoRoca.mp3" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/spotify/rmi/server/Launcher.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/server/Launcher.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/origin/Gwendolyne.mp3" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/spotify/rmi/server/SpotifyServerImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/server/SpotifyServerImpl.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/origin/HablameDeTi.mp3" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/origin/MiGranNoche.mp3" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/origin/Quijote.mp3" afterDir="false" />
<change afterPath="$PROJECT_DIR$/mp3files/origin/coverGwendolyne.jpeg" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -49,40 +45,44 @@ ...@@ -49,40 +45,44 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;Application.Client.executor&quot;: &quot;Run&quot;, "Application.Client.executor": "Run",
&quot;Application.Launcher.executor&quot;: &quot;Run&quot;, "Application.ContinuousReadL.executor": "Run",
&quot;Application.PlayList.executor&quot;: &quot;Run&quot;, "Application.Launcher.executor": "Run",
&quot;Application.PlayRandomSong.executor&quot;: &quot;Run&quot;, "Application.PlayList.executor": "Run",
&quot;Application.PlaySong.executor&quot;: &quot;Run&quot;, "Application.PlayRandomSong.executor": "Run",
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;, "Application.PlaySong.executor": "Run",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "Application.PrimerasOperaciones.executor": "Run",
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;, "Application.SegundasOperaciones.executor": "Run",
&quot;git-widget-placeholder&quot;: &quot;master&quot;, "RunOnceActivity.OpenProjectViewOnStart": "true",
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;last_opened_file_path&quot;: &quot;/home/ismael/IdeaProjects/practicasdis2/src/spotify&quot;, "SHARE_PROJECT_CONFIGURATION_FILES": "true",
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, "git-widget-placeholder": "master",
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;, "kotlin-language-version-configured": "true",
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, "last_opened_file_path": "/home/ismael/IdeaProjects/practicasdis2/src/spotify/media",
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;, "node.js.detected.package.eslint": "true",
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;, "node.js.detected.package.tslint": "true",
&quot;project.structure.last.edited&quot;: &quot;Modules&quot;, "node.js.selected.package.eslint": "(autodetect)",
&quot;project.structure.proportion&quot;: &quot;0.0&quot;, "node.js.selected.package.tslint": "(autodetect)",
&quot;project.structure.side.proportion&quot;: &quot;0.0&quot;, "nodejs_package_manager_path": "npm",
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;, "project.structure.last.edited": "Modules",
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot; "project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.0",
"settings.editor.selected.configurable": "preferences.lookFeel",
"vue.rearranger.settings.migration": "true"
} }
}</component> }]]></component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/spotify/media" />
<recent name="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit" />
<recent name="$PROJECT_DIR$/src/spotify" /> <recent name="$PROJECT_DIR$/src/spotify" />
<recent name="$PROJECT_DIR$/src/sdis/spotify/client/unit" /> <recent name="$PROJECT_DIR$/src/sdis/spotify/client/unit" />
<recent name="$PROJECT_DIR$/src/sdis/spotify/client" /> <recent name="$PROJECT_DIR$/src/sdis/spotify/client" />
<recent name="$PROJECT_DIR$/src/sdis/spotify/common" />
<recent name="$PROJECT_DIR$/src/sdis/spotify/server" />
</key> </key>
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/covers" />
<recent name="$PROJECT_DIR$/mp3files/origin" /> <recent name="$PROJECT_DIR$/mp3files/origin" />
</key> </key>
<key name="CopyClassDialog.RECENTS_KEY"> <key name="CopyClassDialog.RECENTS_KEY">
...@@ -114,7 +114,9 @@ ...@@ -114,7 +114,9 @@
<workItem from="1716193421391" duration="5004000" /> <workItem from="1716193421391" duration="5004000" />
<workItem from="1716289481350" duration="3207000" /> <workItem from="1716289481350" duration="3207000" />
<workItem from="1716300799328" duration="6999000" /> <workItem from="1716300799328" duration="6999000" />
<workItem from="1716309405427" duration="3444000" /> <workItem from="1716309405427" duration="3744000" />
<workItem from="1716376204050" duration="3565000" />
<workItem from="1716384955891" duration="4398000" />
</task> </task>
<task id="LOCAL-00001" summary="l"> <task id="LOCAL-00001" summary="l">
<option name="closed" value="true" /> <option name="closed" value="true" />
...@@ -188,7 +190,15 @@ ...@@ -188,7 +190,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1716312645637</updated> <updated>1716312645637</updated>
</task> </task>
<option name="localTasksCounter" value="10" /> <task id="LOCAL-00010" summary="workspace">
<option name="closed" value="true" />
<created>1716313134057</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1716313134057</updated>
</task>
<option name="localTasksCounter" value="11" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
...@@ -215,6 +225,7 @@ ...@@ -215,6 +225,7 @@
<MESSAGE value="Final ultimo lab" /> <MESSAGE value="Final ultimo lab" />
<MESSAGE value="Cambios, y metadata?¿" /> <MESSAGE value="Cambios, y metadata?¿" />
<MESSAGE value="Las canciones" /> <MESSAGE value="Las canciones" />
<option name="LAST_COMMIT_MESSAGE" value="Las canciones" /> <MESSAGE value="workspace" />
<option name="LAST_COMMIT_MESSAGE" value="workspace" />
</component> </component>
</project> </project>
\ No newline at end of file
covers/coverAmanteBandido.jpg

68 KiB

covers/coverAmigaMia.jpg

23.9 KiB

covers/coverAmorDeHombre.jpg

46.9 KiB

covers/coverAmparitoRoca.jpg

7.87 KiB

File moved
covers/coverHablameDeTi.jpg

39.5 KiB

covers/coverLeon.jpg

8.98 KiB

covers/coverMiGranNoche.jpg

27.2 KiB

covers/coverQuijote.jpg

111 KiB

package spotify.rmi.client;
import java.util.ArrayList;
import java.util.Random;
import spotify.media.Media;
public class CompleteMetadata {
public static void main(String[] args) {
List<Media> mediaList = new ArrayList<>();
// Suponemos que tienes una lista de objetos Media ya creada
for (int i = 0; i < 10; i++) {
mediaList.add(new Media());
}
Random random = new Random();
String[] predefinedComments = {
"Me encanta esta cancion!!!", "De lo mejor que he escuchado", "Muy buena", "No es de mi gusto :(", "Fantastica", "Podria ser mejor, sobretodo la letra es muuuuuy mejorable",
"Buen ritmo, y mejor cantante imposible", "Letra de otro mundo!", "Esta bien", "La disfruto cada vez que la esucho", "Increible ritmo",
"No me gusta", "Bastante buena", "Demasiado fuerte...", "¡Increible!", "Suave, pero mola", "Melodia pegadiza", "Muy repetitiva, a ver si se inventan algo mejor",
"Me encantan las voces de fondo, de pelicula!", "Aburrida..."
};
for (Media media : mediaList) {
// Añadir likes aleatorios entre 0 y 1000
int likes = random.nextInt(1001);
for (int i = 0; i < likes; i++) {
media.addLike();
}
// 30% de probabilidad de contenido adulto
if (random.nextDouble() < 0.3) {
media.tagAdultContent(true);
}
// Añadir de 0 a 20 comentarios aleatorios
int numComments = random.nextInt(21);
for (int i = 0; i < numComments; i++) {
String comment = predefinedComments[random.nextInt(predefinedComments.length)];
media.addComment(comment);
}
// Añadir un número aleatorio de puntuaciones entre 0 y 1000
int numScores = random.nextInt(1001);
for (int i = 0; i < numScores; i++) {
double score = random.nextDouble() * 5; // Puntuación entre 0 y 5
media.addScore(score);
}
}
System.out.println("Relleno de metadatos completado.\n");
}
}
package spotify.rmi.client.stream.unit;
import spotify.rmi.common.Spotify;
import java.rmi.Naming;
import java.util.ArrayList;
import java.util.Scanner;
import spotify.media.Media;
public class ContinuousReadL {
public static void main(String [ ] args) {
String host = "localHost";
Scanner scanner = new Scanner(System.in);
try {
Spotify or = (Spotify) Naming.lookup("rmi://"+host+"/ObjetoSpotify");
System.out.println(or.hello());
String respuesta = or.auth("hector", "1234");
System.out.println("[Respuesta: "+respuesta+"]");
ArrayList<String> cancionesLeidas = new ArrayList<String>();
boolean termina = false;
while(!termina){
Media cancionActual = or.readL();
System.out.println("-------------------------\nLa cancion actual es:" +
cancionActual.toString() +
"\n-------------------------\nIntroduce un caracter para leer la siguiente cancion:\n"
);
cancionesLeidas.add(cancionActual.getName());
scanner.nextLine();
if(or.peekL() == null) {
System.out.println("Ya no hay mas canciones en la playlist.\n");
termina=true;
}
}
for (String cancion : cancionesLeidas) {
if (or.retrieveMedia(cancion) == null) {
System.out.println("[ERROR] Una de las canciones leidas no se encuentra en el direcotrio.\n");
break;
}
}
} catch (java.rmi.RemoteException re) {
System.err.println("<Cliente: Excepción RMI: "+re);
re.printStackTrace();
} catch (Exception e) {
System.err.println("<Cliente: Excepcion: "+e);
e.printStackTrace();
}finally {
scanner.close();
System.exit(0);
}
}
}
...@@ -81,8 +81,7 @@ public class PlayList { ...@@ -81,8 +81,7 @@ public class PlayList {
e.printStackTrace(); e.printStackTrace();
}finally { }finally {
scanner.close(); scanner.close();
System.exit(0); //Mirar esto bien, puede que no haga falta si System.exit(0);
//se cierran los objetos rmi necesarios?¿ pero no estoy seguro de eso
} }
} }
} }
...@@ -6,6 +6,8 @@ import spotify.rmi.client.stream.SpotifyClientImpl; ...@@ -6,6 +6,8 @@ import spotify.rmi.client.stream.SpotifyClientImpl;
import java.rmi.Naming; import java.rmi.Naming;
import java.io.File;
public class PlaySong { public class PlaySong {
public static void main(String [ ] args) { public static void main(String [ ] args) {
String host = "localHost"; String host = "localHost";
...@@ -19,7 +21,8 @@ public class PlaySong { ...@@ -19,7 +21,8 @@ public class PlaySong {
System.out.println("[Respuesta: "+respuesta+"]"); System.out.println("[Respuesta: "+respuesta+"]");
Media media = new Media("Quijote"); Media media = new Media("Quijote");
//media.loadCover("../../../mp3files/origin/coverGwendolyne.jpeg"); media.loadCover("./covers/coverQuijote.jpg");
or.add2L(media); or.add2L(media);
SpotifyClientImpl orCliente = new SpotifyClientImpl(); SpotifyClientImpl orCliente = new SpotifyClientImpl();
...@@ -30,7 +33,7 @@ public class PlaySong { ...@@ -30,7 +33,7 @@ public class PlaySong {
String respMedia = orServer.startMedia(media); String respMedia = orServer.startMedia(media);
System.out.println("[Respuesta: "+respMedia+"]"); System.out.println("[Respuesta: "+respMedia+"]");
media.showCover();
} catch (java.rmi.RemoteException re) { } catch (java.rmi.RemoteException re) {
System.err.println("<Cliente: Excepción RMI: "+re); System.err.println("<Cliente: Excepción RMI: "+re);
...@@ -41,4 +44,9 @@ public class PlaySong { ...@@ -41,4 +44,9 @@ public class PlaySong {
} }
} }
public static boolean fileExists(String path) {
File file = new File(path);
return file.exists() && file.isFile();
}
} }
package spotify.rmi.client.stream.unit;
import spotify.media.Media;
import spotify.rmi.client.stream.SpotifyClientImpl;
import spotify.rmi.common.Spotify;
import spotify.rmi.common.SpotifyServer;
import java.rmi.Naming;
public class PrimerasOperaciones {
public static void main(String [ ] args) {
String host = "localHost";
//System.setProperty("java.rmi.server.hostname","ip");
try {
SpotifyServer orServer = (SpotifyServer) Naming.lookup("rmi://"+host+"/ObjetoSpotify");
Spotify or = (Spotify) Naming.lookup("rmi://"+host+"/ObjetoSpotify");
String saludo = or.hello();
System.out.println(saludo);
String respuestaMala = or.auth("amparito", "roca");
System.out.println("[Respuesta: "+respuestaMala+"]");
String respuestaBuena = or.auth("hector", "1234");
System.out.println("[Respuesta: "+respuestaBuena+"]");
System.out.println("[Add2L de dos canciones a default]");
Media media = new Media("AmorDeHombre");
media.loadCover("./covers/coverAmorDeHombre.jpg");
or.add2L(media);
Media media2 = new Media("HablameDeTi");
media2.loadCover("./covers/coverHablameDeTi.jpg");
or.add2L(media2);
System.out.println("[Add2L de dos canciones a ThisIsJulioIglesias]");
Media media3 = new Media("Gwendolyne");
media3.loadCover("./covers/coverGwendolyne.jpg");
or.add2L("ThisIsJulioIglesias",media3);
Media media4 = new Media("Quijote");
media4.loadCover("./covers/coverQuijote.jpg");
or.add2L("ThisIsJulioIglesias",media4);
Media mediaLeida = or.readL("ThisIsJulioIglesias");
System.out.println("ReadL ha leido de ThisIsJulioIglesias: " + mediaLeida.getName());
mediaLeida.showCover();
mediaLeida = or.readL();
System.out.println("ReadL ha leido de DEFAULT: " + mediaLeida.getName());
mediaLeida = or.readL();
System.out.println("ReadL ha leido de DEFAULT: " + mediaLeida.getName());
mediaLeida = or.readL();
System.out.println("ReadL ha leido de DEFAULT: " + mediaLeida.getName());
mediaLeida = or.peekL();
System.out.println("PeekL ha leido de DEFAULT: " + mediaLeida.getName());
SpotifyClientImpl orCliente = new SpotifyClientImpl();
if(!orServer.setClientStreamReceptor(orCliente)){
System.out.println("Error al poner el receptor del stream");
}
String respMedia = orServer.startMedia(mediaLeida);
System.out.println("[Respuesta: "+respMedia+"]");
mediaLeida.showCover();
while(orCliente.isMediaPlayerActive()){
Thread.sleep(2000);
}
String respuesta = or.deleteL("ThisIsJulioIglesias");
System.out.println("[Respuesta: "+respuesta+"]");
respuesta = or.deleteL("ThisIsJulioIglesias");
System.out.println("[Respuesta: "+respuesta+"]");
} catch (java.rmi.RemoteException re) {
System.err.println("<Cliente: Excepción RMI: "+re);
re.printStackTrace();
} catch (Exception e) {
System.err.println("<Cliente: Excepcion: "+e);
e.printStackTrace();
}
}
}
package spotify.rmi.client.stream.unit;
import spotify.media.Media;
import spotify.rmi.client.stream.SpotifyClientImpl;
import spotify.rmi.common.Spotify;
import spotify.rmi.common.SpotifyServer;
import java.rmi.Naming;
public class SegundasOperaciones {
public static void main(String [ ] args) {
String host = "localHost";
//System.setProperty("java.rmi.server.hostname","ip");
try {
SpotifyServer orServer = (SpotifyServer) Naming.lookup("rmi://"+host+"/ObjetoSpotify");
Spotify or = (Spotify) Naming.lookup("rmi://"+host+"/ObjetoSpotify");
//Saludo
String saludo = or.hello();
System.out.println(saludo);
// Se loggea correctamente
String respuestaBuena = or.auth("hector", "1234");
System.out.println("[Respuesta: "+respuestaBuena+"]");
// Se enseña el directorio
String directorio = or.getDirectoryList();
System.out.println(directorio);
// Se enseña la cancion antes de cambiar el cover
Media media = or.retrieveMedia("AmigaMia");
System.out.println("Se saca la cancion: "+media.getName());
media.showCover();
// Se prepara objeto remoto de cliente
SpotifyClientImpl orCliente = new SpotifyClientImpl();
if(!orServer.setClientStreamReceptor(orCliente)){
System.out.println("Error al poner el receptor del stream");
}
// Se pone la cancion
String respMedia = orServer.startMedia(media);
System.out.println("[Respuesta: "+respMedia+"]");
media.showCover();
// Bucle de espera
while(orCliente.isMediaPlayerActive()){
Thread.sleep(2000);
}
// Se cambia el cover
media.loadCover("./covers/coverLeon.jpg");
String respuesta = or.setCover(media);
System.out.println("[Respuesta: "+respuesta+"]");
// Se saca la cancion con el cover cambiado
media = or.retrieveMedia("AmigaMia");
System.out.println("Se saca la cancion: "+media.getName());
media.showCover();
// Se crea nuevo media
Media mediaNuevo = new Media("MiGranNoche");
media.loadCover("./covers/coverMiGranNoche.jpg");
// Se añade a la lista DEFAULT y se imprime informacion
or.add2L(mediaNuevo);
System.out.println(mediaNuevo.toString());
// Se cambia la informacion de la cancion
or.addScore("MiGranNoche",4.0);
or.addScore("MiGranNoche",5.0);
or.addComment("MiGranNoche","Raphael el mejor!");
or.addComment("MiGranNoche","Vamoos Raphaaaaaa");
// Se saca la cancion con los metadatos cambiados
media = or.retrieveMedia("MiGranNoche");
System.out.println("Se saca la cancion: "+media.getName());
System.out.println(media.toString());
// Se enseña el directorio de nuevo con la nueva cancion
directorio = or.getDirectoryList();
System.out.println(directorio);
} catch (java.rmi.RemoteException re) {
System.err.println("<Cliente: Excepción RMI: "+re);
re.printStackTrace();
} catch (Exception e) {
System.err.println("<Cliente: Excepcion: "+e);
e.printStackTrace();
}
}
}
...@@ -6,6 +6,7 @@ import spotify.rmi.server.utils.MultiMap; ...@@ -6,6 +6,7 @@ import spotify.rmi.server.utils.MultiMap;
import java.rmi.registry.LocateRegistry; import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry; import java.rmi.registry.Registry;
import java.util.HashMap; import java.util.HashMap;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class Launcher { public class Launcher {
...@@ -22,17 +23,57 @@ public class Launcher { ...@@ -22,17 +23,57 @@ public class Launcher {
HashMap<String, Media> DIRECTORIO = new HashMap<>(); HashMap<String, Media> DIRECTORIO = new HashMap<>();
Media media = new Media("AmanteBandido"); Media media = new Media("AmanteBandido");
media.loadCover("./covers/coverAmanteBandido.jpg");
DIRECTORIO.put(media.getName(),media); DIRECTORIO.put(media.getName(),media);
mapa.push("DEFAULT", media.getName()); mapa.push("DEFAULT", media.getName());
Media media2 = new Media("AmparitoRoca"); Media media2 = new Media("AmparitoRoca");
media2.loadCover("./covers/coverAmparitoRoca.jpg");
DIRECTORIO.put(media2.getName(),media2); DIRECTORIO.put(media2.getName(),media2);
mapa.push("DEFAULT", media2.getName()); mapa.push("DEFAULT", media2.getName());
Media media3 = new Media("AmigaMia"); Media media3 = new Media("AmigaMia");
media3.loadCover("./covers/coverAmigaMia.jpg");
DIRECTORIO.put(media3.getName(),media3); DIRECTORIO.put(media3.getName(),media3);
mapa.push("DEFAULT", media3.getName()); mapa.push("DEFAULT", media3.getName());
Random random = new Random();
String[] predefinedComments = {
"Me encanta esta cancion!!!", "De lo mejor que he escuchado", "Muy buena", "No es de mi gusto :(", "Fantastica", "Podria ser mejor, sobretodo la letra es muuuuuy mejorable",
"Buen ritmo, y mejor cantante imposible", "Letra de otro mundo!", "Esta bien", "La disfruto cada vez que la esucho", "Increible ritmo",
"No me gusta", "Bastante buena", "Demasiado fuerte...", "¡Increible!", "Suave, pero mola", "Melodia pegadiza", "Muy repetitiva, a ver si se inventan algo mejor",
"Me encantan las voces de fondo, de pelicula!", "Aburrida..."
};
for (Media mediaItem : DIRECTORIO.values()) {
// Añadir likes aleatorios entre 0 y 1000
int likes = random.nextInt(1001);
for (int i = 0; i < likes; i++) {
mediaItem.addLike();
}
// 30% de probabilidad de contenido adulto
if (random.nextDouble() < 0.3) {
mediaItem.tagAdultContent(true);
}
// Añadir de 0 a 20 comentarios aleatorios
int numComments = random.nextInt(21);
for (int i = 0; i < numComments; i++) {
String comment = predefinedComments[random.nextInt(predefinedComments.length)];
mediaItem.addComment(comment);
}
// Añadir un número aleatorio de puntuaciones entre 0 y 1000
int numScores = random.nextInt(1001);
for (int i = 0; i < numScores; i++) {
double score = random.nextDouble() * 5; // Puntuación entre 0 y 5
mediaItem.addScore(score);
}
}
try { try {
SpotifyServerImpl oRemoto = new SpotifyServerImpl(mapa, datosLog, DIRECTORIO); SpotifyServerImpl oRemoto = new SpotifyServerImpl(mapa, datosLog, DIRECTORIO);
Registry registro = LocateRegistry.createRegistry(PUERTO); Registry registro = LocateRegistry.createRegistry(PUERTO);
...@@ -43,4 +84,8 @@ public class Launcher { ...@@ -43,4 +84,8 @@ public class Launcher {
e.printStackTrace(); e.printStackTrace();
} }
} }
public void completeData(HashMap<String, Media> DIRECTORIO, MultiMap<String, String> mapa){
}
} }
...@@ -53,11 +53,7 @@ public class SpotifyServerImpl ...@@ -53,11 +53,7 @@ public class SpotifyServerImpl
putDirectorio(media); putDirectorio(media);
}; };
public void add2L(String playlist, Media media) throws RemoteException{ public void add2L(String playlist, Media media) throws RemoteException{
if(mapa.contieneClave(playlist)) {
mapa.push(playlist, media.getName()); mapa.push(playlist, media.getName());
}else{
mapa.push("DEFAULT", media.getName());
}
putDirectorio(media); putDirectorio(media);
}; };
public Media readL() throws RemoteException{ public Media readL() throws RemoteException{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment