• Publicidad

Radio X 0.4

¿Estás desarrollando un proyecto, o piensas hacerlo? Pon aquí tu propuesta, lo más seguro es que alguien esté interesado en ayudarte.

Radio X 0.4

Notapor BigBear » 2014-03-29 13:49 @617

Actualicé mi programa en Perl llamado "Radio X" debido a que las emisoras no me gustaban, así que actualicé el hash con 31 estaciones, todas de diferentes géneros, aunque la única que siempre escucho es la de música clásica.

Aclaración de dependencia:

Aclaro que necesitan bajar el Mplayer, está el enalce de descarga en el script. Una vez que lo tengan descargado y descomprimido creen una carpeta llamada "mplayer" y copian todos los archivos del archivo descomprimido en la carpeta recién creada. Todo esto tiene que ser en el mismo directorio donde este el script.

El código:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!usr/bin/perl
  2. #Radio X
  3. #Version 0.4
  4. #(C) Doddy Hackman 2014
  5. #
  6. #Download : http://www.mplayerhq.hu/MPlayer/release ... 1.0rc2.zip
  7. #
  8.  
  9. use Cwd;
  10.  
  11. my @emisoras = (
  12.  
  13.     {},
  14.  
  15.     {
  16.  
  17.         "nombre" => "idobi Radio",
  18.         "genero" => "Alternative",
  19.         "link"   => "http://69.46.88.21:80"
  20.  
  21.     },
  22.  
  23.     {
  24.  
  25.         "nombre" => "BLUES RADIO (1.FM TM)",
  26.         "genero" => "Blues",
  27.         "link"   => "http://205.164.35.58:80"
  28.  
  29.     },
  30.  
  31.     {
  32.  
  33.         "nombre" => "Venice Classic Radio Italia",
  34.         "genero" => "Classical",
  35.         "link"   => "http://174.36.206.197:8000"
  36.  
  37.     },
  38.  
  39.     {
  40.  
  41.         "nombre" => "100hitz - New Country",
  42.         "genero" => "Country",
  43.         "link"   => "http://69.4.234.186:9210"
  44.  
  45.     },
  46.  
  47.     {
  48.  
  49.         "nombre" => "RADIO 7 - POLNOCNE",
  50.         "genero" => "Decades",
  51.         "link"   => "http://94.23.36.107:443"
  52.  
  53.     },
  54.  
  55.     {
  56.  
  57.         "nombre" => "COOLfahrenheit 93",
  58.         "genero" => "Easy Listening",
  59.         "link"   => "http://203.150.225.77:8400"
  60.  
  61.     },
  62.  
  63.     {
  64.  
  65.         "nombre" => "Ibiza Global Radio",
  66.         "genero" => "Electronic",
  67.         "link"   => "http://198.50.197.161:8024"
  68.  
  69.     },
  70.  
  71.     {
  72.  
  73.         "nombre" => "HBR1.com - I.D.M. Tranceponder",
  74.         "genero" => "Trance",
  75.         "link"   => "http://ubuntu.hbr1.com:19800/trance.ogg"
  76.  
  77.     },
  78.  
  79.     {
  80.  
  81.         "nombre" => "COOL radio - Beograd",
  82.         "genero" => "Folk",
  83.         "link"   => "http://176.9.30.66:80"
  84.  
  85.     },
  86.  
  87.     {
  88.  
  89.         "nombre" => "COOL radio - Beograd",
  90.         "genero" => "Folk",
  91.         "link"   => "http://176.9.30.66:80"
  92.  
  93.     },
  94.  
  95.     {
  96.  
  97.         "nombre" => "HPR4",
  98.         "genero" => "Inspirational",
  99.         "link"   => "http://50.7.77.179:8024"
  100.  
  101.     },
  102.  
  103.     {
  104.  
  105.         "nombre" => "Radio Carsija - Melli",
  106.         "genero" => "International",
  107.         "link"   => "http://80.237.153.95:19406"
  108.  
  109.     },
  110.  
  111.     {
  112.  
  113.         "nombre" => "TheJazzGroove.com",
  114.         "genero" => "Jazz",
  115.         "link"   => "http://199.180.72.2:8015"
  116.  
  117.     },
  118.  
  119.     {
  120.  
  121.         "nombre" => "Paisa Estereo",
  122.         "genero" => "Latin",
  123.         "link"   => "http://199.217.118.10:7094"
  124.  
  125.     },
  126.  
  127.     {
  128.  
  129.         "nombre" => "RockRadio1.Com",
  130.         "genero" => "Metal",
  131.         "link"   => "http://77.74.192.50:8000"
  132.  
  133.     },
  134.  
  135.     {
  136.  
  137.         "nombre" => "Adom 106.3FM",
  138.         "genero" => "Misc",
  139.         "link"   => "http://67.159.60.45:8100"
  140.  
  141.     },
  142.  
  143.     {
  144.  
  145.         "nombre" => "Healing",
  146.         "genero" => "New Age",
  147.         "link"   => "http://222.122.178.183:11070"
  148.  
  149.     },
  150.  
  151.     {
  152.  
  153.         "nombre" => "RADIO SOUND POP",
  154.         "genero" => "Pop",
  155.         "link"   => "http://99.198.118.250:8076"
  156.  
  157.     },
  158.  
  159.     {
  160.  
  161.         "nombre" => "Latido 90.1 FM",
  162.         "genero" => "Public Radio",
  163.         "link"   => "http://64.251.21.48:42000"
  164.  
  165.     },
  166.  
  167.     {
  168.  
  169.         "nombre" => "Radio Mandela",
  170.         "genero" => "Funk",
  171.         "link"   => "http://184.154.150.93:9010"
  172.  
  173.     },
  174.  
  175.     {
  176.  
  177.         "nombre" => "Boneyaad Radio",
  178.         "genero" => "Rap",
  179.         "link"   => "http://69.175.103.226:8180"
  180.  
  181.     },
  182.  
  183.     {
  184.  
  185.         "nombre" => "Reggae141.com",
  186.         "genero" => "Reggae",
  187.         "link"   => "http://184.107.197.154:8002"
  188.  
  189.     },
  190.  
  191.     {
  192.  
  193.         "nombre" => "Classic Rock 915",
  194.         "genero" => "Rock",
  195.         "link"   => "http://117.53.175.113:15018"
  196.  
  197.     },
  198.  
  199.     {
  200.  
  201.         "nombre" => "181.fm - Rock 181 (Active Rock)",
  202.         "genero" => "Rock",
  203.         "link"   => "http://108.61.73.118:14008"
  204.  
  205.     },
  206.  
  207.     {
  208.  
  209.         "nombre" => "181.FM - The Buzz",
  210.         "genero" => "Rock",
  211.         "link"   => "http://108.61.73.119:14126"
  212.  
  213.     },
  214.  
  215.     {
  216.  
  217.         "nombre" => "181.FM - Good Time Oldies",
  218.         "genero" => "Rock",
  219.         "link"   => "http://108.61.73.118:14046"
  220.  
  221.     },
  222.  
  223.     {
  224.  
  225.         "nombre" => "Top40",
  226.         "genero" => "Pop Dance R&B Rock",
  227.         "link"   => "http://95.141.24.79:80"
  228.  
  229.     },
  230.  
  231.     {
  232.  
  233.         "nombre" => "MUSIK.ORIENTAL",
  234.         "genero" => "Seasonal and Holiday",
  235.         "link"   => "http://193.34.51.40:80"
  236.  
  237.     },
  238.  
  239.     {
  240.  
  241.         "nombre" => "NOVA 100.3",
  242.         "genero" => "Soundtracks",
  243.         "link"   => "http://117.53.175.113:15010"
  244.  
  245.     },
  246.  
  247.     {
  248.  
  249.         "nombre" => "Alex Jones - Infowars.com",
  250.         "genero" => "Talk",
  251.         "link"   => "http://50.7.130.109:80"
  252.  
  253.     },
  254.  
  255.     {
  256.  
  257.         "nombre" => "illusive Radio Punta",
  258.         "genero" => "Themes",
  259.         "link"   => "http://38.96.148.141:9996"
  260.  
  261.     }
  262.  
  263. );
  264.  
  265. $SIG{INT} = \&retorno;
  266.  
  267. chdir( getcwd() . "/mplayer/" );
  268.  
  269. menu();
  270.  
  271. sub retorno {
  272.     print "\n\n[+] Press any key for return to the menu\n\n";
  273.     <stdin>;
  274.     clean();
  275.     menu();
  276. }
  277.  
  278. sub menu {
  279.  
  280.     head();
  281.  
  282.     print "\n\n[+] Listing ["
  283.       . int( @emisoras - 1 ) . "] "
  284.       . "stations found ...\n";
  285.  
  286.     for my $em ( 1 .. @emisoras - 1 ) {
  287.  
  288.         print "\n[+] ID : " . $em . "\n";
  289.         print "[+] Name : " . $emisoras[$em]->{nombre} . "\n";
  290.         print "[+] Type : " . $emisoras[$em]->{genero} . "\n";
  291.  
  292.         #print "[$em] - ".$emisoras[$em]->{genero}."\n";
  293.  
  294.     }
  295.  
  296.     print "\n[+] Write exit to go out\n";
  297.  
  298.     print "\n[+] Option : ";
  299.     chomp( my $op = <stdin> );
  300.  
  301.     if ( $op eq "exit" ) {
  302.         copyright();
  303.     }
  304.  
  305.     if ( $op =~ /\d+/ ) {
  306.         print "\n[!] Listening : " . $emisoras[$op]->{link} . " ...\n\n";
  307.         system("mplayer $emisoras[$op]->{link}");
  308.     }
  309.  
  310.     copyright();
  311.  
  312. }
  313.  
  314. sub head {
  315.  
  316.     clean();
  317.  
  318.     print qq(
  319.  
  320.  
  321.  @@@@@     @    @@@@    @   @@@@     @     @
  322.  @    @    @    @   @   @  @    @    @     @
  323.  @    @   @ @   @    @  @  @    @     @   @
  324.  @    @   @ @   @    @  @  @    @      @ @  
  325.  @@@@@   @   @  @    @  @  @    @       @  
  326.  @    @  @   @  @    @  @  @    @      @ @  
  327.  @    @  @@@@@  @    @  @  @    @     @   @
  328.  @    @ @     @ @   @   @  @    @    @     @
  329.  @    @ @     @ @@@@    @   @@@@     @     @
  330.  
  331. );
  332.  
  333. }
  334.  
  335. sub copyright {
  336.     print "\n\n-- == (C) Doddy Hackman 2014 == --\n\n";
  337.     <stdin>;
  338.     exit(1);
  339. }
  340.  
  341. sub clean {
  342.     my $os = $^O;
  343.     if ( $os =~ /Win32/ig ) {
  344.         system("cls");
  345.     }
  346.     else {
  347.         system("clear");
  348.     }
  349. }
  350.  
  351. #The End ?
  352.  
  353.  
Coloreado en 0.007 segundos, usando GeSHi 1.0.8.4


Un ejemplo de uso

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting



 @@@@@     @    @@@@    @   @@@@     @     @
 @    @    @    @   @   @  @    @    @     @
 @    @   @ @   @    @  @  @    @     @   @
 @    @   @ @   @    @  @  @    @      @ @
 @@@@@   @   @  @    @  @  @    @       @
 @    @  @   @  @    @  @  @    @      @ @
 @    @  @@@@@  @    @  @  @    @     @   @
 @    @ @     @ @   @   @  @    @    @     @
 @    @ @     @ @@@@    @   @@@@     @     @



[+] Listing [31] stations found ...

[+] ID : 1
[+] Name : idobi Radio
[+] Type : Alternative

[+] ID : 2
[+] Name : BLUES RADIO (1.FM TM)
[+] Type : Blues

[+] ID : 3
[+] Name : Venice Classic Radio Italia
[+] Type : Classical

[+] ID : 4
[+] Name : 100hitz - New Country
[+] Type : Country

[+] ID : 5
[+] Name : RADIO 7 - POLNOCNE
[+] Type : Decades

[+] ID : 6
[+] Name : COOLfahrenheit 93
[+] Type : Easy Listening

[+] ID : 7
[+] Name : Ibiza Global Radio
[+] Type : Electronic

[+] ID : 8
[+] Name : HBR1.com - I.D.M. Tranceponder
[+] Type : Trance

[+] ID : 9
[+] Name : COOL radio - Beograd
[+] Type : Folk

[+] ID : 10
[+] Name : COOL radio - Beograd
[+] Type : Folk

[+] ID : 11
[+] Name : HPR4
[+] Type : Inspirational

[+] ID : 12
[+] Name : Radio Carsija - Melli
[+] Type : International

[+] ID : 13
[+] Name : TheJazzGroove.com
[+] Type : Jazz

[+] ID : 14
[+] Name : Paisa Estereo
[+] Type : Latin

[+] ID : 15
[+] Name : RockRadio1.Com
[+] Type : Metal

[+] ID : 16
[+] Name : Adom 106.3FM
[+] Type : Misc

[+] ID : 17
[+] Name : Healing
[+] Type : New Age

[+] ID : 18
[+] Name : RADIO SOUND POP
[+] Type : Pop

[+] ID : 19
[+] Name : Latido 90.1 FM
[+] Type : Public Radio

[+] ID : 20
[+] Name : Radio Mandela
[+] Type : Funk

[+] ID : 21
[+] Name : Boneyaad Radio
[+] Type : Rap

[+] ID : 22
[+] Name : Reggae141.com
[+] Type : Reggae

[+] ID : 23
[+] Name : Classic Rock 915
[+] Type : Rock

[+] ID : 24
[+] Name : 181.fm - Rock 181 (Active Rock)
[+] Type : Rock

[+] ID : 25
[+] Name : 181.FM - The Buzz
[+] Type : Rock

[+] ID : 26
[+] Name : 181.FM - Good Time Oldies
[+] Type : Rock

[+] ID : 27
[+] Name : Top40
[+] Type : Pop Dance R&B Rock

[+] ID : 28
[+] Name : MUSIK.ORIENTAL
[+] Type : Seasonal and Holiday

[+] ID : 29
[+] Name : NOVA 100.3
[+] Type : Soundtracks

[+] ID : 30
[+] Name : Alex Jones - Infowars.com
[+] Type : Talk

[+] ID : 31
[+] Name : illusive Radio Punta
[+] Type : Themes

[+] Write exit to go out

[+] Option : 3

[!] Listening : http://174.36.206.197:8000 ...

MPlayer 1.0rc2-4.2.1 (C) 2000-2007 MPlayer Team
CPU: AMD Sempron(tm) 140 Processor (Family: 16, Model: 6, Stepping: 2)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.

Playing http://174.36.206.197:8000.
Connecting to server 174.36.206.197[174.36.206.197]: 8000...
Name   : Venice Classic Radio Italia
Genre  : Classical
Website: http://www.veniceclassicradio.eu/
Public : yes
Bitrate: 128kbit/s
Cache size set to 320 KBytes
Cache fill:  0.00% (0 bytes)   No bind found for key ''.

Cache fill:  7.50% (24576 bytes)
ICY Info: StreamTitle='Frederic Chopin (1810-1849) - 'Allegro de concert' per pi
anoforte in la Maggiore Op.46 (11:37)  {+info: veniceclassicradio.eu}';StreamUrl
='';
Cache fill: 17.50% (57344 bytes)
Audio file file format detected.
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
mpg123: Can't rewind stream by 154 bits!
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
AO: [dsound] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...

ICY Info: StreamTitle='Mauro Giuliani (1781-1829) - Variazioni su 'Deh! Calma, o
h ciel!' per chitarra e quartetto (08:00)  {+info: veniceclassicradio.eu}';Strea
mUrl='';

ICY Info: StreamTitle='Johann Sebastian Bach (1685-1750) - 'Il clavicembalo ben
temperato' - Libro I - Praeludium et Fuga in si bemolle Maggiore BWV866 (02:42)
 {+info: veniceclassicradio.eu}';StreamUrl='';

ICY Info: StreamTitle='Antonio Palella (1692-1761) - Concerto a 4  in sol Maggio
re (12:42)  {+info: veniceclassicradio.eu}';StreamUrl='';

ICY Info: StreamTitle='Anton Reicha (1770-1836) - Sonata per fagotto e pianofort
e (16:19)  {+info: veniceclassicradio.eu}';StreamUrl='';

ICY Info: StreamTitle='Gioachino Rossini (1792-1868) - Sonata per archi in mi be
molle Maggiore No.5 (14:51)  {+info: veniceclassicradio.eu}';StreamUrl='';

ICY Info: StreamTitle='Fernand De La Tombelle (1854-1928) - Andante espressivo p
er violoncello e pianoforte (04:39)  {+info: veniceclassicradio.eu}';StreamUrl='
';

ICY Info: StreamTitle='Franz Schubert (1797-1828) - Sinfonia in re Maggiore No.3
 D200 (23:09)  {+info: veniceclassicradio.eu}';StreamUrl='';

 
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4


Eso es todo.
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818

Publicidad

Re: Radio X 0.4

Notapor explorer » 2014-03-29 14:53 @662

¿Y no sería mejor no tener que instalar el mplayer en una determinada carpeta?

Si el Mplayer está instalado en el sistema, será posible localizarlo en alguna de las rutas indicadas por la variable de entorno $PATH (o %PATH%, en Windows).

Y eso quiere decir... que el sistema se ocupa por nosotros para encontrarlo.

Ejemplo:
Sintáxis: [ Descargar ] [ Ocultar ]
  1. explorer@joaquinferrero:~$ which mplayer 
  2. /usr/bin/mplayer 
  3. explorer@joaquinferrero:~$ perl -E 'system("mplayer", "http://222.122.178.183:11070");' 

Como ves, el mplayer está en una ruta conocida (de mi $PATH). Solo tengo que ejecutar el system() con el "mplayer", y el sistema se encarga de buscarlo y ejecutarlo.

Entonces, en tu programa, el único requisito que hay que indicar al usuario es que el "Mplayer esté instalado". Tu programa puede hacer una comprobación previa:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. if (! length qx(mplayer -list-options)) {
  2.     die "Mplayer no está instalado o no lo encuentro\n";
  3. }
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España


Volver a Proyectos

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado

cron