Contenu | Rechercher | Menus

Annonce

Ubuntu-fr vend de superbes t-shirts et de belles clés USB 32Go
Rendez-vous sur la boutique En Vente Libre

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 08/10/2007, à 22:53

oblooblo2000

[resolu]feisty + mythtv + sasc-ng + infinity phoenix

Bonjour a tous,

1/ j'aimerai savoir si la seule solution pour utiliser une carte officelle est sasc-ng. J'ai cru comprendre qu'il fallait coupler ensuite avec newcs, gbox...

2/ Je me suis donc lancé dans la compil comme expliqué ici:

https://opensvn.csie.org/traccgi/sascng/

sudo apt-get install subversion
sudo svn co https://OpenSVN.csie.org/sascng sasc-ng
cd sasc-ng/
cd trunk/
sudo ./configure 
sudo make module
sudo make

et la j'ai des erreurs:

echo 'const char *source_version =' '"'`(svnversion /home/gilc/sasc-ng/trunk 2>/dev/null) || echo Unknown`/`(svnversion /home/gilc/sasc-ng/trunk/dvbloopback 2>/dev/null) || echo Unknown`'";' > .vers.new ; diff .vers.new objs/version.cpp > .vers.diff 2>&1 ; if test -s .vers.diff ; then mv -f .vers.new objs/version.cpp ; fi ; rm -f .vers.new .vers.diff
make -C ./sc/PLUGINS/src/sc-src  CXX=g++ SASC=1 STATIC=1 all
sed: impossible de lire ../../../ci.c: Aucun fichier ou répertoire de ce type
grep: ../../../i18n.c: Aucun fichier ou répertoire de ce type
make[1]: entrant dans le répertoire « /home/gilc/sasc-ng/trunk/sc/PLUGINS/src/sc-src »
g++ -O2 -g -fPIC -Wall -Woverloaded-virtual -c -DPLUGIN_NAME_I18N='"sc"' -DSASC -DAPIVERSNUM=10505 -D_GNU_SOURCE -DSTATICBUILD -I../../../include crypto.c
Dans le fichier inclus à partir de crypto.c:24:
crypto.h:32:33: erreur: openssl/opensslconf.h : Aucun fichier ou répertoire de ce type
crypto.h:33:30: erreur: openssl/opensslv.h : Aucun fichier ou répertoire de ce type
crypto.h:36:2: erreur: #error Openssl version 0.9.7 or newer is strongly recomended
Dans le fichier inclus à partir de crypto.h:39,
          à partir de crypto.c:24:
crypto-bn.h:23:24: erreur: openssl/bn.h : Aucun fichier ou répertoire de ce type
crypto.c:91:2: attention : #warning ** openssl lacks IDEA support. Using deprecated static support code. Update your openssl package.
crypto.c:385:2: attention : #warning ** openssl lacks AES support. Using deprecated static support code. Update your openssl package.
crypto-bn.h:34: erreur: «BIGNUM" does not name a type
crypto-bn.h:38: erreur: expected type-specifier before «BIGNUM"
crypto-bn.h: In constructor «cBN::cBN()":
crypto-bn.h:36: erreur: «big" was not declared in this scope
crypto-bn.h:36: erreur: «BN_init" was not declared in this scope
crypto-bn.h: In destructor «cBN::~cBN()":
crypto-bn.h:37: erreur: «big" was not declared in this scope
crypto-bn.h:37: erreur: «BN_free" was not declared in this scope
crypto-bn.h: At global scope:
crypto-bn.h:47: erreur: ISO C++ forbids declaration of «BN_CTX" with no type
crypto-bn.h:47: erreur: expected «;" before «*" token
crypto-bn.h:51: erreur: expected type-specifier before «BN_CTX"
crypto-bn.h: In constructor «cBNctx::cBNctx()":
crypto-bn.h:49: erreur: «ctx" was not declared in this scope
crypto-bn.h:49: erreur: «BN_CTX_new" was not declared in this scope
crypto-bn.h: In destructor «cBNctx::~cBNctx()":
crypto-bn.h:50: erreur: «ctx" was not declared in this scope
crypto-bn.h:50: erreur: «BN_CTX_free" was not declared in this scope
crypto.h: At global scope:
crypto.h:131: erreur: expected «," or «..." before «*" token
crypto.h:131: erreur: ISO C++ forbids declaration of «BIGNUM" with no type
crypto.h:132: erreur: «BIGNUM" has not been declared
crypto.h:132: erreur: expected «," or «..." before «*" token
crypto.h:132: erreur: ISO C++ forbids declaration of «BIGNUM" with no type
crypto.h:133: erreur: «BIGNUM" has not been declared
crypto.h:133: erreur: expected «," or «..." before «*" token
crypto.h:133: erreur: ISO C++ forbids declaration of «BIGNUM" with no type
crypto.c: In member function «bool cBN::Get(const unsigned char*, int)":
crypto.c:54: erreur: «big" was not declared in this scope
crypto.c:54: erreur: «BN_bin2bn" was not declared in this scope
crypto.c: In member function «int cBN::Put(unsigned char*, int) const":
crypto.c:59: erreur: «big" was not declared in this scope
crypto.c:59: erreur: «BN_num_bytes" was not declared in this scope
crypto.c:62: erreur: «BN_bn2bin" was not declared in this scope
crypto.c:68: erreur: «BN_bn2bin" was not declared in this scope
crypto.c:70: erreur: «BN_bn2bin" was not declared in this scope
crypto.c: In member function «bool cBN::GetLE(const unsigned char*, int)":
crypto.c:78: erreur: «big" was not declared in this scope
crypto.c:78: erreur: «BN_bin2bn" was not declared in this scope
crypto.c: At global scope:
crypto.c:157: erreur: expected «," or «..." before «*" token
crypto.c:157: erreur: ISO C++ forbids declaration of «BIGNUM" with no type
crypto.c: In member function «int cRSA::RSA(unsigned char*, const unsigned char*, int, int) const":
crypto.c:161: erreur: «LE" was not declared in this scope
crypto.c:162: erreur: «exp" was not declared in this scope
crypto.c:162: erreur: «mod" was not declared in this scope
crypto.c:162: erreur: «BN_mod_exp" was not declared in this scope
crypto.c: At global scope:
crypto.c:168: erreur: «int cRSA::RSA" is not a static member of «class cRSA"
crypto.c:168: erreur: «BIGNUM" was not declared in this scope
crypto.c:168: erreur: «out" was not declared in this scope
crypto.c:168: erreur: expected primary-expression before «const"
crypto.c:168: erreur: expected primary-expression before «int"
crypto.c:168: erreur: expected primary-expression before «const"
crypto.c:168: erreur: expected primary-expression before «const"
crypto.c:168: erreur: expected primary-expression before «bool"
crypto.c:168: erreur: initializer liste d'expressions traitée comme une expression composée
crypto.c:168: erreur: expected «," or «;" before «const"
crypto.c:179: erreur: «BIGNUM" has not been declared
crypto.c:179: erreur: expected «," or «..." before «*" token
crypto.c:179: erreur: ISO C++ forbids declaration of «BIGNUM" with no type
crypto.c: In member function «int cRSA::RSA(unsigned char*, int, int*, int) const":
crypto.c:183: erreur: «exp" was not declared in this scope
crypto.c:183: erreur: «mod" was not declared in this scope
crypto.c:183: erreur: «BN_mod_exp" was not declared in this scope
crypto.c:183: erreur: «LE" was not declared in this scope
make[1]: *** [crypto.o] Erreur 1
make[1]: quittant le répertoire « /home/gilc/sasc-ng/trunk/sc/PLUGINS/src/sc-src »
make: *** [sc-plugin] Erreur 2

j'ai l'impression qu'il y a un pb avec libcrypto, openssl qui est a jour pourtant, libssl qui a l'air de ne pas etre dans les depots et mes headers dvb qui sont normalement avec le noyau??? A moins que je doits les telecharger (sources)

apres il faut je crois patcher mythtv
et puis je doits enfin faire le lien avec mon infinity usb phoenix avec newcs je penses.

Je tatonne, ah oui j'utilise une hauppauge nova s plus (dvb-s) qui marche avec cx88-dvb

Merci pour toute aide.

Dernière modification par oblooblo2000 (Le 14/10/2007, à 00:09)

Hors ligne

#2 Le 09/10/2007, à 20:35

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

ok j'ai reussi a compiler en installant avant le make:

sudo apt-get install libc6-dev kernel-package libqt3-mt-dev libncurses-dev libttf-dev libqt4-core libqt4-dev mysql-common mysql-server phpmyadmin xmltv xmltv-gui build-essential fakeroot qt3-dev-tools libqt3-mt-dev liblircclient-dev libasound2-dev libdts-dev libdvdnav-dev libxv-dev libxvmc-dev libxxf86vm-dev libqt3-mt-mysql libxxf86vm-dev libqt3-mt-mysql subversion libdvdread3-dev libsamplerate0 subversion libsamplerate0 liba52-0.7.4-dev liba52-0.7.4-dev libcdio-dev kdelibs4-dev flac flac123 libflac-dev libcdaudio-dev libxml-simple-perl libxml-rss-perl exif libexif-dev liblame-dev liblame0 lame libssl-dev

comme indiqué ici
https://opensvn.csie.org/traccgi/sascng/wiki/Ubuntubuild
http://mythtv.pbwiki.com/MythTV+och+SASC-NG

Si vous avez un probleme avec le configure, un sudo apt-get install g++ peu aider (sous linuxmce)

Maintenant il faut que j'installe newcs et l'interface avec smartcard.conf, je croits.
A suivre.

Dernière modification par oblooblo2000 (Le 24/10/2007, à 22:15)

Hors ligne

#3 Le 09/10/2007, à 21:18

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

d'ailleurs si cela sert a quelqu un les versions compiler sont la:
http://www.zshare.net/download/4114002fe7df10/

config:
mythtv 0.20-svn20070122-0.0ubuntu6 (via apt-get)
kernel a jour 2.6.20-16-generic
ubuntu feisty

Hors ligne

#4 Le 09/10/2007, à 22:37

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

bon voici le newcs.xml que j'utilise avec mon infinity usb phoenix sur port com 1:

<newCSconfig>

<readers name="Card Readers">
<device>
<name>phoenix</name>
<type>Phoenix</type>
<node>/dev/ttyS0</node>
<mhz>600</mhz> <!-- or 357 -->
<parity>even</parity>
<export>yes</export>
<enabled>yes</enabled>
<blocksa>No</blocksa>
<blockua>No</blockua>
<blockga>No</blockga>
<!-- <boxkey>0000000000</boxkey> -->
<PTShandshake>no</PTShandshake>
<crypto-special>no</crypto-special>
<carddetect>no</carddetect>
<newcamd_port>10001</newcamd_port>
<priority>round</priority> <!-- hard is default -->
<sid>
<allow>
<!-- valid value for id are:
4 numbers, if the service id is 3 numbers, add a 0 infront of it. -->
<id></id>
</allow>
<deny>
<!-- valid value for id are:
4 numbers, if the service id is 3 numbers, add a 0 infront of it. -->
<id></id>
</deny>
</sid>
</device>


</readers>

<radegastserver>
<!-- valid value for enable are:
0,1 - Enable or Disable radegast server. -->
<enabled>no</enabled>

<!-- valid value for port are:
0,65535 - Which port to listen for incomming connections. -->
<port>10001</port>

<!-- valid value for allow are:
ALL - Not active yet. -->
<allow>
<hostname>127.0.0.1</hostname>
</allow>
</radegastserver>
<cache>
<emm>10</emm>
<ecm>10</ecm>
</cache>
<debug>
<level>normal</level>
<type>init</type>
<output>all</output>
<logfile></logfile>
<console_options></console_options>
<file_options></file_options>
<udp_host>192.168.1.10</udp_host>
<udp_port>1000</udp_port>
<udp_options></udp_options>
<tcp_port>3001</tcp_port>
<tcp_options></tcp_options>
</debug>
<newcamdserver>
<enabled>yes</enabled>
<name>bla</name>
<deskey>0102030405060708091011121314</deskey>
<userfile></userfile>
<user>
<name>test</name>
<password>test</password>
<au>on</au>
</user>
<!-- Remove if you dont use reverse login -->
<user>
<name>User2</name>
<password>Pass2</password>
<hostname>localhost</hostname>
<port>12345</port>
<spider>yes</spider>
</user>


</newcamdserver>
</newCSconfig>

Je n'ai pas encore eu le temps de le parametrer a ma sauce !!
Maintenant reste a lier mythtv et sasc-ng, comme indiqué ici a priori:
https://opensvn.csie.org/traccgi/sascng/wiki/SascMythTV

Puis lier sasc-ng avec newcs !
risque d'etre plus coton

A priori il y avait plus simple en modifiant uniquement le fichier sc_files/smartcard.conf et donc se passer de newcs !

Hors ligne

#5 Le 10/10/2007, à 18:22

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

En fait voici d'autres infos utiles:
http://www.omcentre.com.au/Getting-Pay-TV-to-Work-With-MythTV.102.0.html

avec newcs, o doit parametrer le serveur radegast, puis parametrer dans sasc, le fichier cardclient.conf:
The only file I'm putting there is cardclient.conf that has the configuration
to connect to the newcamd server (radegast) that controls the smartcard.

Reste plus qu'a trouver un exemple !!!

Hors ligne

#6 Le 10/10/2007, à 18:30

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

ok, les exemples de fichiers se trouvent dans:
sasc-ng/trunk/sc/PLUGINS/src/sc-src/examples

2 solutions, smartcard.conf a configurer et dans ce cas, on se passe de newcs

I've never used ST19 and it's been a long time since I used a smartcard at all, but make sure you read the directions in sc/PLUGINS/src/sc-src. You must specify the 'DEFAULT_PORT in sasc's Makefile via:
SCOPTS = 'DEFAULT_PORT="/dev/ttyS0",0,0,0'

dans mon cas, c'est ok

2eme solution on parametre newcs je croits en serveur radegast, puis le fichiers sc_files/cardclient.conf de sasc-ng. Je me demande si on est obligé de passer par newcamd... ou est ce que newcs peut dialoguer directement avec sasc

Dernière modification par oblooblo2000 (Le 10/10/2007, à 19:03)

Hors ligne

#7 Le 10/10/2007, à 19:06

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

Pour la 2eme solution, je croits qu'on a pas le choix !!
newcs + newcamd (ou radegast, cccam, gbox...) + sasc (cardclient.conf) + carte virtuelle tv dans mythtv (carte reele decryptee)

EDIT: Je me reprends, en fait on peut s'en passer, newcs + sasc marche ensemble:

/etc/newcs.xml:

<newCSconfig>

<readers name="Card Readers">
<device>
<name>phoenix</name>
<type>Phoenix</type>
<node>/dev/ttyS0</node>
<mhz>357</mhz> <!-- or 357 -->
<parity>even</parity>
<export>yes</export>
<enabled>yes</enabled>
<blocksa>No</blocksa>
<blockua>No</blockua>
<blockga>No</blockga>
<!-- <boxkey>0000000000</boxkey> -->
<PTShandshake>no</PTShandshake>
<crypto-special>no</crypto-special>
<carddetect>no</carddetect>
<newcamd_port>10000</newcamd_port>
<priority>round</priority> <!-- hard is default -->
<sid>
<allow>
<!-- valid value for id are:
4 numbers, if the service id is 3 numbers, add a 0 infront of it. -->
<id></id>
</allow>
<deny>
<!-- valid value for id are:
4 numbers, if the service id is 3 numbers, add a 0 infront of it. -->
<id></id>
</deny>
</sid>
</device>


</readers>

<cache>
<emm>10</emm>
<ecm>10</ecm>
</cache>
<debug>
<level>normal</level>
<type>init</type>
<output>all</output>
<logfile></logfile>
<console_options></console_options>
<file_options></file_options>
<udp_host>localhost</udp_host>
<udp_port>11000</udp_port>
<udp_options></udp_options>
<tcp_port>11001</tcp_port>
<tcp_options></tcp_options>
</debug>

<newcamdserver>
<enabled>yes</enabled>
<name>grencam</name>
<deskey>0102030405060708091011121314</deskey>
<userfile></userfile>
<user>
	<name>test</name>
	<password>test</password>

         <au>on</au>
         <spider>No</spider>
         <sidoverride>No</sidoverride>
         <readers>
         <allow>phoenix</allow>
         </readers> 
</user>

</newcamdserver>
</newCSconfig>

changer le port vers /dev/ttyUSB1 dans le cas d'un cable usb2serial

sasc-ng/trunk/sc_files/cardclient.conf:

#
# Comment lines can start with # or ;
#
# every client line starts with the client name, followed by some arguments:
# 'hostname' is the name of the server
# 'port'     is the port on the server
# 'emm'      is a flag to allow EMM transfers to the server
#            (0=disabled 1=enabled)
# 'caid'     (optional) caid on which this client should work
# 'mask'     (optional) mask for caid e.g. caid=1700 mask=FF00 would allow
#            anything between 1700 & 17FF.
#            Default is 1700 & FF00. If only caid is given mask is FFFF.
#            You may give multiple caid/mask values comma separated
#            (e.g. 1702,1722,0d0c/ff00).
# 'username' is the login username
# 'password' is the login password
#
# radegast client
#radegast:hostname:port:emm/caid/mask
#
# aroureos client
# 'hexbase'
# 'hexserial' card data for which EMM updates should be send
#aroureos:hostname:port:emm/caid/mask:hexbase:hexserial
#
# camd33 client (tcp protocol)
# 'aeskey'   is the AES key (32bytes), disable encryption if missing
#camd33:hostname:port:emm/caid/mask:username:password:aeskey
#
# camd35 client (udp protocol)
#camd35:hostname:port:emm/caid/mask:username:password
#
# cardd client
#cardd:hostname:port:emm/caid/mask:username:password
#
# buffy client
# 'aeskey'   is the AES key (32bytes), disable encryption if missing
#buffy:hostname:port:emm:username:password:aeskey

#some examples
#newcamd:192.168.0.10:10000:1/1801/FF00:mythtv:xxxxxxxx:XXXXXXXXXXXXXXXXXXXXXXXXXXXX
#radegast:192.168.0.10:10001:1/1801/FF00 
#
# newcamd client
# 'cfgkey' is the config key (28bytes)
#newcamd:hostname:port:emm/caid/mask:username:password:cfgKey
newcamd:127.0.0.1:10000:1/1801/FF00:test:test:0102030405060708091011121314
#
# gbox client
#
# NOTE: hostname & port will be ignore. GBOX must be runnning on the local
# machine. For convinience you should choose localhost:8004
#gbox:hostname:port:emm/caid/mask

Avec ces deux configs ca marche:

sudo /home/gilc/sasc-ng/trunk/sasc-ng -j 0:1
sudo /home/gilc/newcs-1_31/bin/newcs.i686.usb

Reste qu'a parametrer la carte virtuelle dans le backend.

Dernière modification par oblooblo2000 (Le 03/11/2007, à 16:08)

Hors ligne

#8 Le 11/10/2007, à 03:13

zenacim

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

bonjour,

tu as l'air de t y connaitre.

Je possède un infinity USB mais je connais pas la marche a suivre pour l'installer sous 7.04

peux m'aider stp


ASUS X55V - Ubuntu 14.04 LTS

Hors ligne

#9 Le 11/10/2007, à 14:09

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

zenacim a écrit :

bonjour,

tu as l'air de t y connaitre.

Je possède un infinity USB mais je connais pas la marche a suivre pour l'installer sous 7.04

peux m'aider stp

salut, non mais je decouvre et c'est hard quant meme.

Pour ton probleme, que veux tu faire reelement?? Quel soft tu veux utiliser (kaffeine, vdr, mythtv...)??
Quel infinity as tu phoenix, unlimited ???
QU'est ce qui te bloque ?
A plus

Hors ligne

#10 Le 11/10/2007, à 21:28

zenacim

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

salut je possede un Infinity USB "Phoenix Compatible"

je souhaiterai pouvoir manipuler les cartes à puces que je possède


ASUS X55V - Ubuntu 14.04 LTS

Hors ligne

#11 Le 12/10/2007, à 09:02

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

salut, soit un peu plus précis / a mes autres questions

Hors ligne

#12 Le 13/10/2007, à 21:59

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

ok je continue, a priori, il faut patcher myththtv pour le lien avec sasc:
http://dvbn.happysat.org/viewtopic.php?t=41499&highlight=mythtv+sasc

Merci a torxbit

#These are the plugins for Mythtv. The revision you check out MUST match the revision of mythtv above
svn co http://cvs.mythtv.org/svn/trunk/mythplugins

#These are the patches you run against Mythtv so it will work with Dishnet/Expressview (and a few others I do not know off the top of my head).
svn co http://opensvn.csie.org/myth_dvb_ng

#This is the sasc code to emulate a CAM and decrypt the stream.
svn co http://opensvn.csie.org/sascng

These steps imply you know something about Linux. It is not meant as a HOWTO for someone who is completely new (that excersise is damn near futile and is covered on many sites on the Internet anyway).
1) Install whatever Linux you want, configure its devices and ensure it works.
2) Load on a compiler (gcc and g++) comes to mind, as well as some libraries. If you compile and find you have errors from "missing" statements this usually means you are missing some -dev package.
3) Get those 4 pieces above.
4) Copy the patches you need from the myth-dvb-ng above to the mythtv directory you downloaded in step 1. If you do not know what patched you need there are many places here to tell you. Which ones depends on how you plan to use the software and on what DVB cards. The general command is:

patch -p0 -F99 < whatever.diff

This implies you are in the directory to patch (the -p0) and that you want to to be forgiving on how far off the lines can differ (-F99). If you have ANY failed chucks STOP. You need newer patches (unless you know what a diff is and can apply the failed segments by hand).
5) Go to the directory you downloaded mythtv to and configure and make the software. What options you need to put in your configure again greatly depend on what hardware you have.
6) Install it, then go to the mythplugins directory.
7) Like in step 6, configure and make again. If things do not show up here it is again because you are missing libraries. If you failed to install mythtv above this will fail as you are missing its libraries. When you are done install these (yes I am implying you have both frontend and backend on the same box).
Cool No go to the sascng/trunk directory, and configure the software. If you have an AMD processor read on these forums how to fix the code.
9) Go to the dvbloopback/module directory and type make. If this works you should have a dvbloopback.ko file. If it fails the most common reason is you do not have the kernel source code on the system (it is needed as you are making a custom module for your kernel). If you have problems here, again search the forums.
10) Copy that dvbloopback.ko to the modules direcotry (commonly /lib/modules/<kernel>). Then type "depmod -a". If there are errors here, stop and go back to step 9.
11) type "modprobe dvbloopback" if you have more then one card or need other options again search the forums.
12) go to the sascng/trunk directory and type 'make". If it works you should have a sasc-ng binary. After this you need to search the forums and get some parts external to this site (no I am not going to tell you where to get a key file). Setting up sasc to work with mythtv is in the stickies above.

Hors ligne

#13 Le 13/10/2007, à 23:15

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

En fait le patch est necessaire uniquement pour le nord americain !!
En fait Il faut faire pointer mythtv vers le virtual device 1
(en gros on a le 0 qui est le tunner reel, le 1 devient le 0+decodage de sasc lui meme discutant avec newcs connecté a la carte... oufff compliqué quant meme !)

Donc reste ce point a regler sachant que la commande sasc bloque quant le backend fonctionne (en gros je pense qu'il acced au tuner), donc je pense quant liant le backend de mythtv a la carte 1 (virtuelle), sasc fonctionnera !!
a suivre

Hors ligne

#14 Le 13/10/2007, à 23:36

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

Bon en fait dans carte dvb de mythtv backend il suffit de changer le numéro d'adaptateur qui etait a 0 vers 1. Et de relancer le parametrage automatique !!
Du coup sasc marche, c'etait bien ca !!
Par contre, je suis un peu degouté car en mettant l'adaptateur a 1, dans le frontend de mythtv, je n'ai pas de signal !! En clair il y a un truc que j'ai mal fait !!
Je penses que c'est avec le configure de sasc !!! je ne me rapele pas si j'ai mis des options ??
a suivre !

Hors ligne

#15 Le 14/10/2007, à 00:08

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

oblooblo2000 a écrit :

Je penses que c'est avec le configure de sasc !!! je ne me rapele pas si j'ai mis des options ??
a suivre !

Ca y est, a les louia !!! Ca marche !!!
En fait ca vennait pas du configure, mais du dvbloopback.ko

sudo rmmod dvbloopback.ko
sudo rm /home/gilc/sasc-ng/trunk/dvbloopback.ko

sudo make #recreer le sasc-ng
sudo make module #recreer le dvbloopback module
sudo insmod dvbloopback.ko
sudo ./sasc-ng -j 0:1 #lancer sasc et creer l'adaptateur virtuel 1 basé sur le 0

dans le cas de deux cartes:
sudo ./sasc-ng -j 0:2 -j 1:3

Dernière modification par oblooblo2000 (Le 25/10/2007, à 19:49)

Hors ligne

#16 Le 14/10/2007, à 00:19

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

c'etait encore plus c*n que ca:

sudo /etc/init.d/mythtv-backend stop
sudo /etc/init.d/mythtv-backend start

puis relancer newcs
puis sasc
puis myth frontend

Hors ligne

#17 Le 14/10/2007, à 00:43

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

sasc au demarrage:

creer script

sudo vim /etc/init.d/sasc
chmod 755 /etc/init.d/sasc

cd /etc/rc5.d
sudo ln -s ../init.d/sasc S40sac

to make it run level 5




L'autre solution peut etre:

ln  -s  /script/mythtv/newcs/newcs.i686   ~/.kde/Autostart/newcs
ln  -s  /script/mythtv/sasc/sasc-ng   ~/.kde/Autostart/sasc
ln  -s  mythtv-backend   ~/.kde/Autostart/mythtv-backend


ou encore:
l faut créer un script du type

Code sasc.sh:

#!/bin/sh
/etc/init.d/mythtv-backend stop
/script/mythtv/newcs/bin/newcs.i686
/script/mythtv/sasc/sasc-ng -j 0:1
/etc/init.d/mythtv-backend start
mythfrontend


Tu le mets dans ~/.kde/Autostart
puis tu le rends exécutable et le setuid

Code:

sudo chmod +x ton_script
sudo chmod 6775 ton_script

Dernière modification par oblooblo2000 (Le 16/10/2007, à 19:11)

Hors ligne

#18 Le 15/10/2007, à 22:42

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

Pour ma part j'ai fait un petit script, et un lien:
dans l'autostart vers
ln -s /usr/bin/mythfrontend

Puis le script simple dans /etc/init.d

#! /bin/bash
#
# sasc start-stop script
# Updated 1-9-07  - version 7
# Script by opacus
#
# IMPORTANT: Copy dvbloopback.ko (or link it) to  /lib/modules/2.6.XX/misc
#            after that run "depmod -a" so the modprobe works without being in the current directory.

# Change to 1 to enable sasc-ng's init-script
ENABLED=1

NAME="sasc"                               # name of this program
LOOPDRIVER=" dvbloopback"                  # name of dvbloopback module
SASCDIR="/script/mythtv/sasc/"           # sasc-ng directory
SASCPRG="sasc-ng"                          # name of sasc-ng program
ADDLPRG="mythbackend"                      # additional program (mythbackend or vdr) to be started
ADDLDIR="/usr/local/bin/"                  # additional program directory

# If no add-l program is desired leave an empty field. ie: ADDLPROG= " "

# Add here your dvb card or remote control drivers which may be loaded and unloaded.
# CAUTION: The order of drivers is critical. Drivers with dependants must be at the end of the list
# THE WRONG ORDER OF DRIVERS MAY CRASH YOUR SYSTEM
# this is an example for ati-rc and genpix-usb:
# ADDLDRIVERS=" dvb-usb-gp8psk lirc_atiusb lirc-dev dvb-usb dvb-core dvb-pll"
# this is an example for nexus-s card:
#ADDLDRIVERS=" ves1x93 stv0297 sp8870 tda8083 ves1820 l64781 lnbp21 ttpci_eeprom stv0299 saa7146_vv saa7146 dvb_ttpci dvb_core" 
#ADDLDRIVERS=""

# Startup Options passed to dvbloopback driver:  Adjust according to your number of dvb cards.
LOOPDRIVEROPTION=" num_adapters=1 "

# Startup Options passed to SASC-NG. 
# Adjust according to your devices. You can also use multiple dvb card arguments joined
# SASCOPTION=" --cam-dir=/video/plugins -r 0 -v 1 -o  "   # this is an example for sasc-ng R1 - R66
SASCOPTION=" -j 0:1 "         # this is an example for sasc-ng R67 ->

# Number of times runsasc will attempt to restart SASC-NG after a crash has occured (set to 0 for no limit)
MAXTRIES=3

## End Configuration Section ##

test "$ENABLED" != "0" || exit 0

SASCCMD="$SASCDIR$SASCPRG $SASCOPTION"
LOOPCOUNT=1
LOOP=0
TIMEOUT=200



# Load all DVBLoopback driver modules needed for your hardware:
function LoadDrivers()
{
          echo -e "Stopping mythtv-backend \n"
          sudo /etc/init.d/mythtv-backend stop
          sleep 5

          echo -e "Starting newcs \n"
          #/script/mythtv/newcs/bin/newcs.i686&
          screen -D -m -S newcs-screen  /script/mythtv/newcs/bin/newcs.i686&
          sleep 5
          cd /script/mythtv/sasc
          echo -e "Starting dvbloopback \n"

          #insmod dvbloopback.ko num_adapters=<# of cards>
          #modprobe -aqv /script/mythtv/sasc/dvbloopback.ko
          sudo insmod /script/mythtv/sasc/dvbloopback.ko num_adapters=1
          sleep 5

          echo -e "Starting sasc \n"
          #/script/mythtv/sasc/sasc-ng -j 0:1&
          #screen -D -m -S sasc-screen  /script/mythtv/sasc/sasc-ng -j 0:2 -j 1:3&
          screen -D -m -S sasc-screen  /script/mythtv/sasc/sasc-ng -j 0:1&


          sleep 5

          echo -e "Restarting mythtv-backend \n"
          sudo /etc/init.d/mythtv-backend start
}

# Unload all DVBLoopback driver modules loaded in LoadDrivers 
function UnloadDrivers()
{
          screen -wipe >/dev/null 2>&1
          killall -q -TERM "newcs.i686"
          sleep 2
          killall -q -TERM "sasc-ng"
          sleep 2
          rmmod dvbloopback.ko
          sleep 2
}


case "$1" in
     start)
         echo -e "Starting $SASCPRG \n"
         LoadDrivers
    ;;
     stop)
         echo -e "Stopping $SASCPRG and unloading drivers \n"
         UnloadDrivers
    ;;
     restart | reload | force-reload)
         echo -e "Restarting $SASCPRG \n"
         UnloadDrivers
         LoadDrivers
    ;;
     *)
         echo "Use: $N {start|stop|restart|reload|force-reload}" >&2
         ;;
esac
exit 1

si plusieurs adaptateurs modifier le script:
insmod dvbloopback.ko num_adapters=<# of cards>

Dernière modification par oblooblo2000 (Le 25/10/2007, à 20:55)

Hors ligne

#19 Le 16/10/2007, à 18:26

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

j'ai mis a jour mon script car pour que sasc trouve le fichier cardclient.conf, il faut se trouver dans le repertoire du script sasc.
Je penses qu'en l'ajoutant au path, ca doit marcher aussi !!

Bon maintenant je passe a la config de lirc !!
Je suis alle dans aptitude et j'ai installé lirc !!!

sudo apt-get install lirc lirc-modules-source module-assistant

si on veux re construire a chaque changement de kernel avec les sources de lirc
sudo dpkg-reconfigure lirc-modules-source

+ d infos ici
https://help.ubuntu.com/community/Install_Lirc_Feisty

J'ai modifié le fichier:
lircd.conf pour ma hauppauge (compatible en tout cas car avec la nova s plus, la telecommande est une a415 ou a415-hpg-we-a :

begin remote
  name            Hauppauge_350  
  bits            13  
  flags           RC5|CONST_LENGTH  
  eps             30  
  aeps            100  
  one             969   811  
  zero            969   811  
  gap             114605  
  toggle_bit      2  
  plead           1097  

  begin codes
       Go              0x00000000000017BB
       Power           0x00000000000017BD
       TV              0x000000000000179C
       Videos          0x0000000000001798
       Music           0x0000000000001799
       Pictures        0x000000000000179A
       Guide           0x000000000000179B
       Radio           0x000000000000178C
       Up              0x0000000000001794
       Left            0x0000000000001796
       Right           0x0000000000001797
       Down            0x0000000000001795
       OK              0x00000000000017A5
       Back/Exit       0x000000000000179F
       Menu/i          0x000000000000178D
       Vol+            0x0000000000001790
       Vol-            0x0000000000001791
       Prev.Ch         0x0000000000001792
       Mute            0x000000000000178F
       Ch+             0x00000000000017A0
       Ch-             0x00000000000017A1
       Record          0x00000000000017B7
       Stop            0x00000000000017B6
       Rewind          0x00000000000017B2
       Play            0x00000000000017B5
       Forward         0x00000000000017B4
       Replay/SkipBackward 0x00000000000017A4
       Pause           0x00000000000017B0
       SkipForward     0x000000000000179E
       1               0x0000000000001781
       2               0x0000000000001782
       3               0x0000000000001783
       4               0x0000000000001784
       5               0x0000000000001785
       6               0x0000000000001786
       7               0x0000000000001787
       8               0x0000000000001788
       9               0x0000000000001789
       Asterix         0x000000000000178A
       0               0x0000000000001780
       #               0x000000000000178E
       Red             0x000000000000178B
       Green           0x00000000000017AE
       Yellow          0x00000000000017B8
       Blue            0x00000000000017A9

  end codes

end remote

En tout cas les fleches marche

######puis modifier le code pour l'utilisateur mythtv (lorsque je lance le prog je presume)
######/home/mythtv/.mythtv/lircrc
puis modifier le code pour ~/.lircrc (lorsque je lance le prog je presume)
sudo vim .lircrc


# ~/.mythtv/lircrc
#
# MythTV native LIRC config file for
# the new grey Hauppauge remote
#
# Modified from Jarod Wilson's which came from Jeff Campbell's
# By Brad Templeton


# Here we have the jump point commands.  They only work if you have
# defined function keys for these jump points.  For me the most
# common command is the menu of recordings, so I put that on "videos"
# even though that's counter-intuitive

begin
prog = mythtv
button = TV
repeat = 3
config = F5
end

begin
prog = mythtv
button = Videos
repeat = 3
config = F2
end

# Not yet defined
begin
prog = mythtv
button = Music
repeat = 3
config = Up
end

# Given another function for now, I don't use mythgallery
begin
prog = mythtv
button = Pictures
repeat = 3
config = F
end

begin
prog = mythtv
button = Guide
repeat = 3
config = F3
end

# I stuck the "todo" list on here as Myth has no radio function
begin
prog = mythtv
button = Radio
repeat = 3
config = F4
end

begin
prog = mythtv
button = UP
repeat = 3
config = Up
end

begin
prog = mythtv
button = DOWN
repeat = 3
config = Down
end

begin
prog = mythtv
button = LEFT
repeat = 3
config = Left
end

begin
prog = mythtv
button = RIGHT
repeat = 3
config = Right
end

# Channel Up
begin
prog = mythtv
button = Channel-UP
repeat = 3
config = Up
end

# Channel Down
begin
prog = mythtv
button = Channel-DOWN
repeat = 3
config = Down
end

# OK/Select
begin
prog = mythtv
button = Ok
config = Space
end

# Play
begin
prog = mythtv
button = Play
config = Return
end

# Stop
begin
prog = mythtv
button = Stop
config = I
end

# Escape/Exit/Back
begin
prog = mythtv
button = Back/Exit
config = Esc
end

# Power Off/Exit
begin
prog = mythtv
button = Power
config = Esc
end


# Pause
begin
prog = mythtv
button = Pause
repeat = 3
config = P
end

# Mute
begin
prog = mythtv
button = Mute
repeat = 3
config = |
end

# Fast forward (30 sec default)
begin
prog = mythtv
button = Rewind
repeat = 3
config = <
end

# Rewind (10 sec default)
begin
prog = mythtv
button = Forward
repeat = 3
config = >
end

# Skip forward (10 min default)
begin
prog = mythtv
button = Next
repeat = 3
config = End
end

# Skip backward (10 min default)
begin
prog = mythtv
button = Previous
repeat = 3
config = Home
end

# Record
begin
prog = mythtv
button = Record
repeat = 3
config = R
end

# Delete
begin
prog = mythtv
button = Red
repeat = 3
config = D
end

# Decrease play speed
begin
prog = mythtv
button = Green
repeat = 3
config = J
end

# Display EPG while in live TV,
# View selected show while in EPG
begin
prog = mythtv
button = Menu
repeat = 3
config = M
end

# Scroll up
begin
prog = mythtv
button = Volume-UP
repeat = 3
config = F11
end

# Scroll down
begin
prog = mythtv
button = Volume-DOWN
repeat = 3
config = F10
end

# Bring up OSD info
begin
prog = mythtv
button = Go
repeat = 3
config = I
end

# Change display aspect ratio
begin
prog = mythtv
button = Prev-Channel
repeat = 3
config = W
end

# double speed watch
begin
prog = mythtv
button = Yellow
repeat = 3
config = J
end

# change tuners
begin
prog = mythtv
button = hash
repeat = 3
config = Y
end

# Bring up Time stretch
begin
prog = mythtv
button = Blue
repeat = 3
config = A
end

# Numbers 0-9

begin
prog = mythtv
button = 0
repeat = 3
config = 0
end

begin
prog = mythtv
button = 1
repeat = 3
config = 1
end

begin
prog = mythtv
button = 2
repeat = 3
config = 2
end

begin
prog = mythtv
button = 3
repeat = 3
config = 3
end

begin
prog = mythtv
button = 4
repeat = 3
config = 4
end

begin
prog = mythtv
button = 5
repeat = 3
config = 5
end

begin
prog = mythtv
button = 6
repeat = 3
config = 6
end

begin
prog = mythtv
button = 7
repeat = 3
config = 7
end

begin
prog = mythtv
button = 8
repeat = 3
config = 8
end

begin
prog = mythtv
button = 9
repeat = 3
config = 9
end


### MPlayer lirc setup

# Show OSD
begin
prog = mplayer
button = MENU
repeat = 3
config = osd
end

# Pause playback
begin
prog = mplayer
button = PAUSE
repeat = 3
config = pause
end

# Skip ahead a minute if playing
# If paused, resume playing
begin
prog = mplayer
button = PLAY
repeat = 3
config = seek +1
end

# Stop playback and exit
begin
prog = mplayer
button = STOP
repeat = 3
config = quit
end

# Mute
begin
prog = mplayer
button = MUTE
repeat = 3
config = mute
end

# Seek back 10 seconds
begin
prog = mplayer
button = REW
repeat = 3
config = seek -10
end

# Seek forward 30 seconds
begin
prog = mplayer
button = FFW
repeat = 3
config = seek +30
end

# Quit
begin
prog = mplayer
button = BACK/EXIT
repeat = 3
config = quit
end

# Seek forward 10 minutes
begin
prog = mplayer
button = SKIP
repeat = 3
config = seek +600
end

# Seek backward 10 minutes
begin
prog = mplayer
button = REPLAY
repeat = 3
config = seek -600
end

# Toggle full-screen
begin
prog = mplayer
button = FULL
repeat = 3
config = vo_fullscreen
end

### Xine lirc setup

begin
prog = xine
button = PLAY
repeat = 3
config = Play
end

begin
prog = xine
button = STOP
repeat = 3
config = Stop
end

begin
prog = xine
button = OFF
repeat = 3
config = Quit
end

begin
prog = xine
button = PAUSE
repeat = 3
config = Pause
end

begin
prog = xine
button = CH+
repeat = 3
config = EventUp
end

begin
prog = xine
button = CH-
repeat = 3
config = EventDown
end

begin
prog = xine
button = VOL-
repeat = 3
config = EventLeft
end

begin
prog = xine
button = VOL+
repeat = 3
config = EventRight
end

begin
prog = xine
button = OK
repeat = 3
config = EventSelect
end

begin
prog = xine
button = BACK/EXIT
repeat = 3
config = Menu
end

begin
prog = xine
button = FFW
repeat = 3
#config = SpeedFaster
config = SeekRelative+60
end

begin
prog = xine
button = REW
repeat = 3
#config = SpeedSlower
config = SeekRelative-60
end

begin
prog = xine
button = FULL
repeat = 3
config = Volume+
end

begin
prog = xine
button = BLANK
repeat = 3
config = Volume-
end

begin
prog = xine
button = MUTE
repeat = 3
config = Mute
end

begin
prog = xine
button = MENU
repeat = 3
config = RootMenu
end

begin
prog = xine
button = SKIP
repeat = 3
config = EventNext
end

begin
prog = xine
button = REPLAY
repeat = 3
config = EventPrior
end

begin
prog = xine
button = GO
repeat = 3
config = OSDStreamInfos
end

begin
prog = xine
button = RED
repeat = 3
config = Quit
end

begin
prog = xine
button = RED
repeat = 3
config = Quit
end

pour l'instant ca marche pas !!!
A suivre

...suite
cat /proc/bus/input/devices
en fait ma carte ir est reconnu et j'ai l'impression que le noyau prend le dessus.
En fait lirc ne fonctionne pas, il faut modifier le hardware.conf pour charger les bons modules !

il y a un lien avec
xmodmap et keycode

a suivre
infos:http://people.mech.kuleuven.be/~wmeeusse/linux.html

sudo apt-get install input-utils
cree un lien entre les event et lirc

cat /proc/bus/input/devices
j'utilise l'event2 dans mon cas
mettre dans /etc/lirc/hardware.conf
LIRCD_ARGS="-H dev/input -d /dev/input/event2"

Dernière modification par oblooblo2000 (Le 18/10/2007, à 20:23)

Hors ligne

#20 Le 16/10/2007, à 18:54

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

Once your file is complete, you'll need to install it as /home/mythtv/.mythtv/lircrc in order for mythfrontend to find it. The trouble is, everything else will expect that file in /home/mythtv/.lircrc - so to work around that, we'll like them together with:

$ ln -s ~/.mythtv/lircrc ~/.lircrc

Create a .lircrc file

If you are intending on using lirc for only IR transmitting, you don't need to create a ~/.lircrc file. If you are going to use it for IR receiving, you will need to create a ~/.lircrc file describing what each of the buttons does for each application you will use lirc in.
The basic syntax is as follows:

begin
prog = PROGRAM
button = REMOTE_BUTTON
config = ACTION
end Where:

PROGRAM is the program you are recording buttons for. Some examples for PROGRAM are mythtv, mplayer, xine, vlc, and irexec.
REMOTE_BUTTON is the name of the button in accordance with what is listed in your /etc/lirc/lircd.conf.
ACTION is the action that will be performed when this button is pressed. You can find a list of actions in the attached .lircrc example file.
Specific Application Notes

Multiple applications can be listed in the .lircrc file, but you will need a seperate begin and end block for each button in eachapplication.

MythTV
If you are using this for mythtv, you will need to create a symbolic link to this file for mythtv to read it.

ln -s ~/.lircrc ~/.mythtv/lircrc
IRexec
irexec is able to interpret keypresses and launch applications when the keys are pressed. The syntax is:

begin
prog = irexec
button = REMOTE_BUTTON
config = APPLICATION
end APPLICATION is simply the path and name of a file marked executable.

Dernière modification par oblooblo2000 (Le 18/10/2007, à 00:58)

Hors ligne

#21 Le 16/10/2007, à 19:34

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

Programmes de telepoche
http://cvs.sourceforge.net/viewcvs.py/xmltv/xmltv/grab/fr/tv_grab_fr?rev=1.23&view=log

copiez le fichier dans:
/usr/bin/tv_grab_fr

su
cp /usr/bin/tv_grab_fr /usr/bin/tv_grab_fr.sav
cp /le_nouveau_fichier_grab /usr/bin/tv_grab_fr
chmod a+x /usr/bin/tv_grab_fr


#!/usr/bin/perl

=head1 NAME

tv_grab_fr - Grab TV listings for France.

=head1 SYNOPSIS

To configure: tv_grab_fr --configure [--config-file FILE] [--gui OPTION]
To grab listings: tv_grab_fr [--output FILE] [--quiet] [--perdays]
Slower, detailed grab: tv_grab_fr --slow [--output FILE] [--days N] [--offset N] [--quiet] [--perdays]
To show capabilities: $0 --capabilities
To show version: $0 --version
Help: tv_grab_fr --help

=head1 DESCRIPTION

Output TV listings for several channels available in France (Hertzian,
Cable/satellite, Canal+ Sat, TPS).  The data comes from
telepoche.guidetele.com.  The default is to grab as many days as possible
from the current day onwards. By default the program description are
not downloaded, so if you want description and ratings, you should
active the --slow option.

B<--configure> Grab channels informations from the website and ask for
channel type and names.

B<--gui OPTION> Use this option to enable a graphical interface to be used.
OPTION may be 'Tk', or left blank for the best available choice.
Additional allowed values of OPTION are 'Term' for normal terminal output
(default) and 'TermNoProgressBar' to disable the use of Term::ProgressBar.

B<--output FILE> Write to FILE rather than standard output.

B<--days N> Grab N days starting from today, rather than as many as
possible. Due to the website organization, the speed is exactly the
same, whatever the number of days is until you activate the --slow
option. If --slow is not specified, --days will thus only filter the
data without speeding up the grabber.

B<--offset N> Start grabbing N days from today, rather than starting
today.  N may be negative. Due to the website organization, N cannot
be inferior to -1.  As with --days, this is only useful for limiting
downloads in --slow mode.

B<--slow> Get additional information from the website, like program
description, reviews and credits.

B<--quiet> Suppress the progress messages normally written to standard
error.

B<--perdays> Activate the "per days" grabbing mode. It is a fallback to use if the
grabber does not return any data in the XML file

B<--capabilities> Show which capabilities the grabber supports. For more
information, see L<http://membled.com/twiki/bin/view/Main/XmltvCapabilities>

B<--version> Show the version of the grabber.

B<--help> Print a help message and exit.

=head1 SEE ALSO

L<xmltv(5)>

=head1 AUTHOR

Sylvain Fabre, centraladmin@lahiette.com
with some patches from :
  - Francois Gouget, fgouget@free.fr
  - Niel Markwick, nielm@bigfoot.com

=cut

# TODO / FIXME
# - perhaps we should internationalize messages and docs?
# - try to detect the language based on the country so we can make use of the
#   set the VO, VF and original title markers
# - due to the layout of the grid program data, a given show can appear more
#   than once, first without an icon and then with the icon. But in such a
#   case we miss the icon
# - fix the character encoding handling. Then we can remove the no warning
#   below
# - detect when the website returns an incomplete page. See the thread at:
#   http://sourceforge.net/mailarchive/message.php?msg_id=15128312
# - detect and workaround the website returning the wrong date for pages
#   generated between midnight and 6am
# - detect and workaround the website cache that keeps returning stale pages
# - extend Get_nice so we don't have to do our own downloads. See the thread
#   at:
#   http://sourceforge.net/mailarchive/message.php?msg_id=15220040
# - fix our Memoize usage so the generated cache file can be reused from one
#   day to the next
# - investigate using the per-day pages which would be more efficient for
#   --days 1 to 5
# - investigate how to better handle France 5 and Arte as they share a single
#   channel for over-the-air broadcasts, but each have their own channel on
#   cable, satellite and ADSL. See the thread at:
#   http://sourceforge.net/mailarchive/message.php?msg_id=15181920

use XMLTV::Usage <<END
$0: get French television listings in XMLTV format
To configure: tv_grab_fr --configure [--config-file FILE]
To grab listings: tv_grab_fr [--output FILE] [--quiet]
Slower, detailed grab: tv_grab_fr --slow [--output FILE] [--days N] [--offset N] [--quiet]
END
  ;

use warnings;
use strict;
use utf8;
use XMLTV::Version '$Id: tv_grab_fr,v 1.74 2007/10/02 20:01:29 reudeudeu Exp $ ';
use XMLTV::Capabilities qw/baseline manualconfig cache/;
use XMLTV::Description 'France';
use Getopt::Long;
use HTML::Entities; # parse entities
use IO::File;
use URI;
use Date::Manip;
use XMLTV;
use XMLTV::Ask;
use XMLTV::ProgressBar;
use XMLTV::Mode;
use XMLTV::Config_file;
use XMLTV::DST;
use LWP;
use XMLTV::Get_nice;
use XMLTV::Memoize;
use File::Temp;
use LWP::Simple;

#***************************************************************************
# Main declarations
#***************************************************************************
my $GRID_BY_CHANNEL = 'http://telepoche.guidetele.com/gtv/semaine?openagent&d=0&c=';
my $GRID_BY_CHANNEL_PER_DAY = 'http://telepoche.guidetele.com/gtv/journee?openagent&';
my $GRID_FOR_CHANNEL = 'http://telepoche.guidetele.com/grille/EMWD-6KWLUE/';
my $SHEET_URL = "http://telepoche.guidetele.com/fiche/emi_";
my $ROOT_URL  = "http://telepoche.guidetele.com";
my $LANG = "fr";
my $MAX_STARS = 4;
my $VERSION   = "021007-01";

# FIXME: Temporary avoid XML warnings (to be investigated)
no warnings;

# Grid id defined by the website according to channel types (needed to build the URL)
my %GridType = (  "HERTZIENNE" => "EMWD-66DGBM",
                  "TNT"        => "EMWD-6B2HZ3",
                  "CABLE/SAT"  => "EMWD-66DGCT",
                  "TPS"        => "EMWD-66DJQG",
                  "CANAL SAT"  => "EMWD-66DJEA",
                  "FREEBOX"    => "EMWD-66DJXL",
                  "ETRANGERES" => "EMWD-66DJAL",
                  "NOUVEAU CANAL SAT" => "MDFA-6ZYMXB" );

# Slot of hours according to the website (needed to build the URL)
my @offsets = (2, 3, 4, 5, 6, 7);
# Slot of days for day per day grabbing 
my @days = (2, 3, 4, 5, 6, 7, 8, 9);

##patch: tigerlol: correction des chevauchements d'horaire
  my $progexist=0;
  my $prevstart;
  my $prevstop;
  my $prevtitle;         
  my %prevprog;
##/patch

#***************************************************************************
# Global variables allocation according to options
#***************************************************************************
XMLTV::Memoize::check_argv('XMLTV::Get_nice::get_nice_aux');
#my ($opt_days,  $opt_help,  $opt_output,  $opt_per_days, $opt_per_weeks, $opt_offset,  $opt_gui, $opt_quiet,  $opt_list_channels, $opt_config_file, $opt_configure, $opt_slow);

##patch: tigerlol: correction des chevauchements d'horaire
my ($opt_days,  $opt_help,  $opt_output,  $opt_per_days, $opt_per_weeks, $opt_offset,  $opt_gui, $opt_quiet,  $opt_list_channels, $opt_config_file, $opt_configure, $opt_slow, $opt_noautocorrect);
##/patch

$opt_quiet  = 0;
# The website is able to store up to nine days from now
my $default_opt_days = 9;
$opt_output = '-'; # standard output
GetOptions('days=i'    => \$opt_days,
     'help'      => \$opt_help,
     'output=s'  => \$opt_output,
     'offset=i'  => \$opt_offset,
     'quiet'     => \$opt_quiet,
     'configure' => \$opt_configure,
     'config-file=s' => \$opt_config_file,
     'gui:s'     => \$opt_gui,
     'list-channels' => \$opt_list_channels,
     'slow' => \$opt_slow, 
     'perdays' => \$opt_per_days,
     'perweeks' => \$opt_per_weeks,
##patch: tigerlol: correction des chevauchements d'horaire
     'noautocorrect' => \$opt_noautocorrect
##/patch
    )
  or usage(0);

#***************************************************************************
# Options processing, warnings, checks and default parameters
#***************************************************************************
die 'Number of days must not be negative'  if (defined $opt_days && $opt_days < 0);
die 'Cannot get more than one day before current day' if (defined $opt_offset && $opt_offset < -1);
usage(1) if $opt_help;

XMLTV::Ask::init($opt_gui);

# The options can be used, but we default them if not set.
$opt_offset = 0 if not defined $opt_offset;
$opt_days = $default_opt_days if not defined $opt_days;

# Force the per days option in all cases
if ( $opt_per_weeks == 0 ) {
  $opt_per_days = 1;
}
  
if ( (($opt_offset + $opt_days) > $default_opt_days) or ($opt_offset > $default_opt_days) ) {
    $opt_days = $default_opt_days - $opt_offset;
    if ($opt_days < 0) {
        $opt_offset = 0;
        $opt_days = $default_opt_days;
    }
    say <<END
The website does not handle more than $default_opt_days days.
So the grabber is now configure with --offset $opt_offset --days $opt_days
END
;
}

##patch: tigerlol: correction des chevauchements d'horaire
if ( $opt_noautocorrect ) {
  print STDERR "Autocorrect DESACTIVE!\n";
} else {
  print STDERR "Autocorrect ACTIVE!\n";
}    
##/patch

#***************************************************************************
# Last init before doing real work
#***************************************************************************
my %results;
my $lastdaysoffset = $opt_offset + $opt_days - 1;
my $checkDummySlot = 0;

# Now detects if we are in configure mode
my $mode = XMLTV::Mode::mode('grab', # default
                        $opt_configure => 'configure',
                        $opt_list_channels => 'list-channels');

# File that stores which channels to download.
my $config_file = XMLTV::Config_file::filename($opt_config_file, 'tv_grab_fr', $opt_quiet);

#***************************************************************************
# Sub sections
#***************************************************************************
sub get_channels( $ );
sub process_channel_grid_page( $$$$ );
sub get_detailed_fic( $$$ );
sub debug_print( @ );

# Set this to 1 of you debug strings
my $DEBUG_FR = 0;
# Internal debug functions
sub debug_print( @ ) {
  if ($DEBUG_FR) { print @_; }
}
  
sub xmlencoding {
    # encode for xml
    $_[0] =~ s/</&lt;/g;
    $_[0] =~ s/>/&gt;/g;
    $_[0] =~ s/&/\%26/g;
    return $_[0];
}

sub tidy {    
    for (my $s = shift) {
      s/\xe2\x80\x99/\'/g;
      s/—/--/g;
      s/…/.../g;
      s/\x{2019}/\'/g;
      decode_entities $_;
      tr/\207\211\200\224/\347\311\055\055/; # bad characters
      tr/\205//d;
      tr/\222/''/;
      s/\234/oe/g;
      s/−/ /g;

      # Remove nasty caracters, thanks to nielm
      s/&ldquo;|&rdquo;|&\#8219;|&\#8220;|&\#x201[89];/&quot/g;
      s/&lsquo;|&rsquo;|&\#8216;|&\#8217;|&\#8218;|&\#x201[cdCD];/\'/g;
      s/&\#8230;|&\#x202[4-7];/.../g;
      s/&\#821[0123];|&\#x201[2-5];/-/g;
      s/&OElig;/OE/g;
      s/&oelig;/oe/g;
      s/&\#x0027/\'/g;
      s/(&\#[0-9]{4,};)//g;
      s/(&\#x[0-9a-zA-Z]{3,};)//g;
      # Not strictly a bad character but it does get in the way.
      s/&nbsp;/ /g;
      tr/\240/ /;
      tr/\t/ /;
      s/([^\012\015\040-\176\240-\377])//g;
      return $_;
    }
}

#***************************************************************************
# Configure mode
#***************************************************************************
if ($mode eq 'configure') {
    XMLTV::Config_file::check_no_overwrite($config_file);
    open(CONF, ">$config_file") or die "Cannot write to $config_file: $!";

    # Get a list of available channels, according to the grid type
    my @gts = sort keys %GridType;
    my @gtnames = map { $GridType{$_} } @gts;
    my @gtqs = map { "Get channels type : $_?" } @gts;
    my @gtwant = ask_many_boolean(1, @gtqs);

    my $bar = new XMLTV::ProgressBar('getting channel lists',
                                    scalar grep { $_ } @gtwant)
                    if not $opt_quiet;
    my %channels_for;
    foreach my $i (0 .. $#gts) {
        my ($gt, $gtw, $gtname) = ($gts[$i], $gtwant[$i], $gtnames[$i]);
        next if not $gtw;
        my %channels = get_channels( $gtname );
        die 'No channels could be found' if not %channels;
        $channels_for{$gt} = \%channels;
        update $bar if not $opt_quiet;
    }
    $bar->finish() if not $opt_quiet;

    my %asked;
    foreach (@gts) {
        my $gtw = shift @gtwant;
        my $gtname = shift @gtnames;
        if ($gtw) {
            my %channels = %{$channels_for{$_}};
            say "Channels for $_";

            # Ask about each channel (unless already asked).
            my @chs = grep { not $asked{$_}++ } sort keys %channels;
            my @names = map { $channels{$_}{name} } @chs;
            my @qs = map { "add channel $_?" } @names;
            my @want = ask_many_boolean(1, @qs);
            foreach (@chs) {
                my $w = shift @want;
                warn("cannot read input, stopping channel questions"), last if not defined $w;
                # Print a config line, but comment it out if channel not wanted.
                print CONF '#' if not $w;
                print CONF "channel $_ $channels{$_}{name};$channels{$_}{icon}\n";
            }
        }
    }
    close CONF or warn "cannot close $config_file: $!";
    say("Finished configuration.");
    exit();
}

#***************************************************************************
# Check mode checking and get configuration file
#***************************************************************************
die if $mode ne 'grab' and $mode ne 'list-channels';

my @config_lines;
if ($mode eq 'grab') {
    @config_lines = XMLTV::Config_file::read_lines($config_file);
}

#***************************************************************************
# Prepare the XMLTV writer object
#***************************************************************************
my %w_args;
if (defined $opt_output) {
    my $fh = new IO::File(">$opt_output");
    die "cannot write to $opt_output: $!" if not defined $fh;
    $w_args{OUTPUT} = $fh;
}

$w_args{encoding} = 'ISO-8859-1';

# In fast mode, the datasource contains data for all days at once,
# so we let XMLTV::Writer filter out the days that the user wanted.
if (not $opt_slow) {
  $w_args{days} = $opt_days;
  $w_args{offset} = $opt_offset;
  $w_args{cutoff} = "000000";
}

my $writer = new XMLTV::Writer(%w_args);
$writer->start
  ({ 'source-info-url'     => 'http://telepoche.guidetele.com/',
     'source-data-url'     => 'http://telepoche.guidetele.com/',
     'generator-info-name' => 'XMLTV',
     'generator-info-url'  => 'http://membled.com/work/apps/xmltv/',
   });

#***************************************************************************
# List channels only case
#***************************************************************************
if ($mode eq 'list-channels') {
    # Get a list of available channels, according to the grid type
    my @gts = sort keys %GridType;
    my @gtnames = map { $GridType{$_} } @gts;
    my @gtqs = map { "List channels for grid : $_?" } @gts;
    my @gtwant = ask_many_boolean(1, @gtqs);

    my %seen;
    foreach (@gts) {
        my $gtw = shift @gtwant;
        my $gtname = shift @gtnames;
        if ($gtw) {
            say  "Now getting grid : $_ \n";
            my %channels = get_channels( $gtname );
            die 'no channels could be found' if (scalar(keys(%channels)) == 0);
            foreach my $ch_did (sort(keys %channels)) {
                my $ch_xid = "C".$ch_did.".telepoche.com";
                $writer->write_channel({ id => $ch_xid,
                                         'display-name' => [ [ $channels{$ch_did}{name} ] ],
                                         'icon' => [{src=>$ROOT_URL.$channels{$ch_did}{icon}}] })
                unless $seen{$ch_xid}++;
            }
       }
     }
     $writer->end();
     exit();
}

#***************************************************************************
# Now the real grabbing work
#***************************************************************************
die if $mode ne 'grab';

#***************************************************************************
# Build the working list of channel name/channel id
#***************************************************************************
my (%channels, $chicon, $chid, $chname);
my $line_num = 1;
foreach (@config_lines) {
    ++ $line_num;
    next if not defined;

    # Here we store the Channel name with the ID in the config file, as the XMLTV id = Website ID
    if (/^channel:?\s+(\S+)\s+([^\#]+);([^\#]+)/) {
        $chid = $1;
        $chname = $2;
        $chicon = $3;
        $chname =~ s/\s*$//;
        $channels{$chid} = {'name'=>$chname, 'icon'=>$chicon};
    } else {
        warn "$config_file:$line_num: bad line $_\n";
    }
}

#***************************************************************************
# Now process the days by getting the main grids.
#***************************************************************************
my @to_get;
warn "No working channels configured, so no listings\n" if not %channels;
my $script_duration = time();

# The website stores channel information by hour area for a whole week !
foreach $chid (sort keys %channels) {
    my $url;
    my $i;
    $writer->write_channel({ id => "C".$chid.".telepoche.com", 'display-name' => [[$channels{$chid}{name}]], 'icon' => [{src=>$channels{$chid}{icon}}]});
    if ( $opt_per_days ) {
      for ($i=$opt_offset+2; $i < $opt_offset+$opt_days+2; $i++ ) {
        $url = $GRID_BY_CHANNEL_PER_DAY . "d=$i&c=$chid&h=0";
        push @to_get, [ $url, $chid, $i ];
      }
    } else {
      foreach (@offsets) {
        $url = $GRID_BY_CHANNEL . "$chid&h=$_";
        push @to_get, [ $url, $chid, $_ ];
      }
    }
}    


my $bar = new XMLTV::ProgressBar('getting listings', scalar @to_get)  if not $opt_quiet;
Date_Init("TZ=UTC");

foreach (@to_get) {
    my ($url, $chid, $slot) = @$_;
    #my $th = threads->new(\&process_channel_grid_page, $writer, $chid, $url, $slot);
    #$th->join();
    process_channel_grid_page($writer, $chid, $url, $slot);
    update $bar if not $opt_quiet;
}

##patch: tigerlol: correction des chevauchements d'horaire
if ( !$opt_noautocorrect ) {
  if ( $progexist ) {
    # Ecriture du programme restant en memoire (au cas ou)
    if ( !$results{$prevprog{start}.$chid} ) {
      #print STDERR "!!!Ecriture du dernier programme sauvegarde: " . $prevtitle . "(" . $prevprog{channel} . ")\n";
      $results{$prevprog{start}.$chid} = "1";
      $writer->write_programme(\%prevprog);
    }
    $progexist = 0;
  }
}
##/patch

$writer->end();
$bar->finish() if not $opt_quiet;

# Print the duration
$script_duration = time() - $script_duration;
print STDERR "Grabber process finished in " . $script_duration . " seconds.\n" if not $opt_quiet;

#***************************************************************************
# Specific functions for grabbing information
#***************************************************************************
sub get_channels( $ ) {
  my $gridid = shift;
  my %channels;
  my $url = $GRID_FOR_CHANNEL.$gridid.'/2_6.html';
    
  # Get the current page
  my $t = get_nice_tree($url);           
    
  debug_print( "URL  : " . $url ."\n");
 
  foreach my $cellTree ( $t->look_down( "_tag", "td", "width", "55", "height", "85" ) ) {
    my $tag = $cellTree->look_down( "_tag", "a", 'href', '#' ); 
    if ($tag != undef) {
      my $chid = $tag->attr('onclick');
      if ( $chid =~ /goChaine\('(.*)','(.*)',''\);/ ) {
        $chid = $1;
        my $imgCell = $cellTree->look_down( "_tag", "img" );
        my $chicon = $imgCell->attr('src');
        my $chname = $imgCell->attr('src');
        $chname =~ s/http:\/\/static.guidetele.com\/c_img\/chaine\///;
        $chname =~ s/\.gif//;
        $chname =~ s/\.GIF//;
        debug_print "Found channel : $chid - " . $chname . "\n";
        $channels{$chid} = {'name' =>  $chname, 'icon' => $chicon };
      }
    }
  }
  $t->delete(); undef $t;
  return %channels;
}

sub process_fucking_damned_page( $$$$$ ) {
  my ($writer, $chid, $myrow, $dateindex, $slot) = @_;
  my ($genre, $lastshowview, $showview, $hours, $starthour, $endhour) = 0;
  my ($title, $subgenre, $star_rating, $datecreate) = 0;

  # Each show is described in a table cell with a 'prog' class
  foreach my $show ($myrow->look_down('_tag', 'td', 'class', 'prog') ) {
    # Each cell contains zero or more links describing the show.
    # - If no information is available for the time slot, then the cell
    #   is empty (&nbsp; actually).
    # - Links with a 'fiche' class have the most details and also point
    #   to the per-show web page with the extra information.
    # - Other links contain less detailed information and no pointer to
    #   a per-show page.
    my $link=$show->look_down('_tag', 'a', 'class', 'fiche') ||
             $show->look_down('_tag', 'a', 'onmouseover', qr/^showmenu/);
    next if (!$link);

    my $line = $link->attr('onmouseover');
    $line =~ (!m/showmenu\(([^""]+)\)/);
    $line =~ m/\'(.*)\',\'(.*)\'/;
    $title = tidy($2);
    my $mydata = $1;
    next if ( $title eq 'Fin des programmes');
    ($hours, $genre, $showview) = split (/<br>/, $mydata);
    next if ( !$hours );
    # Process the title, sometimes a showview field is shown
    $title =~ s/^\d{7,8} //;
    $title =~ s/\\//g;
    if ($title =~ s/\s*([*]+)\s*$//) {
      my $n = length $1;
      if (0 < $n and $n <= $MAX_STARS) {
        $star_rating = $n;
      } elsif ($MAX_STARS < $n) {
        warn "too many stars ($n), expected at most $MAX_STARS\n";
      } else { die }
    }
    die if $title =~ /[*]$/;
    my ($language, $subtitles_language);
    for ($title) {
      s/\s+$//;
      if (s/\s+\(VO\)$//) {
      # Version originale - language is unknown but not French.  There is no way to represent this in the DTD.
    } elsif (s/\s+\(VO sous-titr.e\)$//) {
      # Language unknown, but we know it has French subtitles.
      $subtitles_language = 'fr';
      } elsif (s/\s+\(VF\)$//) {
        # Version francaise.  The title may or may not be translated.
        $language = 'fr';
      }
    }
    # At this point, $title contains title and subtitle (if any), separated by a '-'. We will try to split off the subtitle
    # further down. Process hours, there are like HHhMM
    ($starthour, $endhour)  = split("-", $hours);
    $starthour =~ s/h//g
      or die "Cannot detect start hour from website : $starthour \n";
    $endhour   =~ s/h//g
      or die "Cannot detect end hour from website : $endhour \n";
    # Process the start/stop dates
    my $start = $dateindex.$starthour."00";
    my $stop  = $dateindex.$endhour."00";
    
    # Dummy site : the slot 0-4 of day n is in fact the slot 0-4 for day n+1
    # Again, specific parsing if we are in "per days" mode
    if ( $opt_per_days ) {
      # Check it only after 06:00, sometimes we have shows at 03:00.
      my $myslot = substr($starthour, 0, 2);
      $checkDummySlot = 1 if($myslot > 6);
      if($checkDummySlot && $myslot >= 0 && $myslot < 4) {
        $start = &UnixDate(&DateCalc($start, "+1 day"), "%Y%m%d%H%M%S");
        die 'could not add one day to start time' if not $start;
        $stop  = &UnixDate(&DateCalc($stop, "+1 day"), "%Y%m%d%H%M%S");
        die 'could not add one day to stop time' if not $stop;
      }
    } else {
      if ( $slot == 7 ) {
        my $myslot = substr($starthour, 0, 2);
        die if not $start;
        $start = &UnixDate(&DateCalc($start, "+1 day"), "%Y%m%d%H%M%S")
        if ($myslot >= 0 && $myslot < 4);
        die 'could not add one day to start time' if not $start;
        $stop  = &UnixDate(&DateCalc($stop, "+1 day"), "%Y%m%d%H%M%S");
        die 'could not add one day to stop time' if not $stop;
      }
    }
    # Last check to see if start > stop
    if ( Date_Cmp($start, $stop) > 0 ) {
      $stop = &UnixDate(&DateCalc($stop, "+1 day"), "%Y%m%d%H%M%S");
      die 'could not add one day to stop time' if not $stop;
    }
    # Now set the proper timezone (WT/ST) according to current date
    die if not $start; die if not $stop;
    $start = utc_offset( $start, "+0100");
    $stop  = utc_offset( $stop , "+0100");
    my %prog = (channel  => "C".$chid.".telepoche.com",
        title    => [ [ tidy($title) ] ],             # lang unknown
        start    => $start,
        stop     => $stop
      );
    debug_print("Found title : $title - $start - $stop \n");
    $prog{'star-rating'} = [ "$star_rating/$MAX_STARS" ] if defined $star_rating;
    for ($language) { $prog{language} = [ $_ ] if defined }
    for ($subtitles_language) {
      $prog{subtitles} = [ { type => 'onscreen', language => [ $_ ] } ]
      if defined;
    }
    # Sometimes the genre is not set, so replace it by the showview field
    if (defined $genre and $genre =~ m/Showview : /) {
      $showview = $genre;
      undef $genre;
    }
    # Process the genre, subgenre and date if defined
    if  (defined $genre ) {
      my $genre_tmp;
      ($genre_tmp, $datecreate) = split("-", $genre); 
      if ($datecreate == 0) { 
        #datecreate n'est pas une valeur numerique => on la supprime 
        undef $datecreate; 
      } else { 
        #datecreate est valide 
        $genre=$genre_tmp; 
      } 
      ($genre, $subgenre) = split(",", $genre); 
      for ($genre) { s/^\s+//; s/\s+$//; s/\xA0//; }
      if (defined $subgenre) {
        for ($subgenre) { s/^\s+//; s/\s+$//; s/\xA0//; }
        $prog{category} = [ [ xmlencoding(lc($genre)), $LANG ], [ xmlencoding(lc($subgenre)), $LANG ] ];
      } else {
        $prog{category} = [ [ xmlencoding(lc($genre)), $LANG ] ];
      }
      if (defined $datecreate) {
        for ($datecreate) { s/^\s+//; s/\s+$//; s/\xA0//; }
        $prog{date} = $datecreate ;
      }
    }
    # -2 is an unsane value for the showview code... 
    undef $showview if ($showview =~ /-2/ );
    
    # Process the showview field
    if ( defined $showview ) {
      $showview =~ s/Showview : //;
      for ($showview) { s/^\s+//; s/\s+$//; s/\xA0//; }          
      $prog{showview} = $showview;
      next if ( $showview == $lastshowview );
      $lastshowview = $showview;
    }

    my $img=$show->look_down('_tag', 'img', 'onerror', qr/this\.src=/);
    if ($img) {
      my $url=$img->attr('src');
      # Get the big icon
      $url =~ s%/c_img/v/%/c_img/i/%;
      push @{$prog{icon}}, {src => $url};
    }

    # Now get program description if the longlisting option is set
    if ( $opt_slow && $link->attr('class') eq 'fiche' ) {
      get_detailed_fic( $link->attr('onclick'), \%prog, $title );
    } else {
      # The text for the <a> tag contains the title without the sub-title so we can use that to separate the two. However
      # the text for the <a> tag may have been truncated so it fits the slot on the page. Also some titles may contain
      # a ' - '. Still the heuristic works very well.
      my $subtitle;
      my $text = $link->as_text();
      if ($text =~ s/\.\.\.$//) {
        if ($title =~ s/^\Q$text\E([^-]+)\s+-\s+//) {
          $prog{'title'} = [ [ tidy($text).tidy($1) ] ];
          $prog{'sub-title'} = [ [ tidy($title) ] ];
        }
      }
      elsif ($title =~ s/^\Q$text\E\s+-\s+//) {
        $prog{'title'} = [ [ tidy($text) ] ];
        $prog{'sub-title'} = [ [ tidy($title) ] ];
      }
    }


##patch: tigerlol: correction des chevauchements d'horaire
    if ( !$opt_noautocorrect ) {
      if ( $progexist ) {
        #print STDERR "*** " . $prevprog{channel} . " / " . $prog{channel} . " ***\n";
        if ( $prevprog{channel} ne $prog{channel} ) {
          # changement de chaine on ecrit le dernier programme de la chaine precedente
          # et on remet progexist a 0
          #print STDERR "*************\nChangement de chaine...\n*************\n";
          if ( !$results{$prevprog{start}.$chid} ) {
            #print STDERR "Ecriture du dernier programme sauvegarde: " . $prevtitle . "(" . $prevprog{channel} . ")\n";
            $results{$prevprog{start}.$chid} = "1";
            $writer->write_programme(\%prevprog);
          }
          $progexist = 0;
        }
      }
      if ( !$progexist ) {
        #premier programme => sauvegarde du programme courant
        $prevtitle = tidy($title);
        $prevstart = $start;
        $prevstop = $stop;
        %prevprog = %prog;
        $progexist = 1;
      } else {
        #print STDERR "prev. channel = " . $prevprog{channel} . "\n";
        #print STDERR "current channel = " . $prog{channel} . "\n";
        #il existe deja un programme
        #if (( $prog{start} > $prevprog{start} ) && ( $prog{stop} != $prevprog{stop} )) {
        if ( $prog{start} > $prevprog{start} ) {
          # programme courant != programme sauvegarde
          my $savedstop = $prevprog{stop};
          #print STDERR "savedstop = $savedstop\n";
          if ( $prevprog{stop} > $prog{start} ) {
            #chevauchement => modification de l'heure de fin du programme precedent
            #print STDERR "Chevauchement:\n";
            #print STDERR "  - " . $prevtitle . " (start: " . $prevprog{start} . " / stop: " . $prevprog{stop} . ")\n";
            #print STDERR "  - " . $title . " (start: " . $start . " / stop: " . $stop . ")\n";
            $prevprog{stop} = $prog{start};
          }
          if ( $prevprog{stop} - $prevprog{start} > 400 ) {
            #prevprog n'est pas trop court donc ecriture du programme precedent
            if ( !$results{$prevprog{start}.$chid} ) {
              #print STDERR "Ecriture du programme: " . $prevtitle . "(" . $prevprog{channel} . ")\n";
              $results{$prevprog{start}.$chid} = "1";
              $writer->write_programme(\%prevprog);
            }
          } else {
            if (( $savedstop == $prog{stop} ) || ( $prevprog{title} eq $prog{title} )) {
              #prevprog est un programme trop court ou duplique => on le zap! ;-)
              #et on modifie le start du programme courant avant de le sauvegarder
              my $dureeprog = $prevprog{stop} - $prevprog{start};
              #print STDERR "Programme court zappe: $prevtitle ($dureeprog)\n";
              $prog{start} = $prevprog{start};
              $start = $prog{start};
            } else {
              #prevprog est valide, on l'ecrit...
              if ( !$results{$prevprog{start}.$chid} ) {
                #print STDERR "Ecriture du programme: " . $prevtitle . "(" . $prevprog{channel} . ")\n";
                $results{$prevprog{start}.$chid} = "1";
                $writer->write_programme(\%prevprog);
              }
            }
          }
          #sauvegarde du programme courant
          $prevtitle = tidy($title);
          $prevstart = $start;
          $prevstop = $stop;
          %prevprog = %prog;
        } else {
          debug_print("Date of previous program is not correct\n"); 
          if ($prog{stop} < $prevprog{start} ){ 
             # bcp plus simple que precedement : vu qu on identifie un programme 
             # qui precede avec des dates superieures, cela signifie en fait que 
             # le programme date du jour precedent et qu un jour lui a ete rajoute 
             # par erreur. La solution est de supprimer le programme precedent. 
             $prevtitle = tidy($title); 
             $prevstart = $start; 
             $prevstop = $stop; 
             %prevprog = %prog; 
          }
        }
      }
    } else {
      if ( !$results{$prog{start}.$chid} ) {
        $results{$prog{start}.$chid} = "1";
        $writer->write_programme(\%prog);
      }
    }
##/patch
  }
}

sub process_channel_grid_page( $$$$ ) {
    my ($writer, $chid, $url, $slot) = @_;
    my ($genre, $lastshowview, $showview, $hours, $starthour, $endhour, $date, $dateindex) = 0;
    my ($title, $subgenre, $star_rating, $datecreate) = 0;
    $checkDummySlot = 0;
       
    # Get the current page
    my $t = get_nice_tree($url);
    debug_print("Now getting page : $url\n");
    
    # Reset some working variables
    my $day = 0; my $month = 0; my $year = 0;

    if ( my $tableTree = $t->look_down('_tag', 'table', 'width', '600', 'height', '70', 'bgcolor', '#ffffff') ) {
      # Get the list of rows of the table
      my @dateRowTab = $tableTree->content_list();
      # Now loop thru rows
      foreach my $dateRow (@dateRowTab) {
        my $daterow = $dateRow->look_down('_tag', 'td', 'width', '403');
        if ( $daterow ) {
          my $startdate = $daterow->as_text();
          if ( $opt_per_days ) {
            $startdate =~ /^Les programmes de la journ.*e\s+du\s+(\d+)\/(\d+)\/(\d+)/;
            $day = $1; $month = $2; $year = $3;
          } else {
            $startdate =~ /^Les programmes de la semaine du (\d+)\/(\d+)\/(\d+)/;
            $day = $1; $month = $2; $year = $3;
          }
        }
      }
    }
    
    # If we are grabbing in "per days" mode, then enter here
    if ( $opt_per_days) {
      $date = DateCalc($month."/".$day."/".$year, "+0 days");
      $dateindex = UnixDate($date, "%Y%m%d");
      foreach my $tableTree ($t->look_down('_tag', 'table', 'width', '655')) {
        # Skip table which do not contain program
        next if(!$tableTree->look_down('_tag', 'td', 'class', 'prog'));
        process_fucking_damned_page( $writer, $chid, $tableTree, $dateindex, $slot);
      }
    # Default old per week grabbing process
    } else {
      if ( my $tableTree = $t->look_down('_tag', 'table', 'width', '655', 'class', 'prog_grille') ) {
        foreach my $myrow ( $tableTree->look_down('_tag', 'tr') ) {
          if ( my $celldate = $myrow->look_down('_tag', 'td', 'width', '55', 'height', '42' ) ) {
            my $myday = $celldate->as_text();
            $myday =~ /^(\d+)\/(\d+)/;
            $day = $1; $month = $2;
          }
          debug_print "Now parsing date : $day $month \n";
          $date = DateCalc($month."/".$day."/".$year, "+0 days");
          $dateindex = UnixDate($date, "%Y%m%d");
          # We need to limit the number of days fetched in slow mode, but in fast mode no limit is needed since
          # there is a single fetch for all days.
          if ($opt_slow) {
            next if Date_Cmp($dateindex, UnixDate(DateCalc("today", "+$opt_offset days"),"%Y%m%d")) < 0;
            next if Date_Cmp($dateindex, UnixDate(DateCalc("today", "+$lastdaysoffset days"),"%Y%m%d")) > 0;
          }
          process_fucking_damned_page( $writer, $chid, $myrow, $dateindex, $slot);
          $myrow->replace_with("REPLACED");
      }
    }
  }
  $t->delete(); undef $t;
}

sub text_cleanup( $ )
{
  my ($desc) = @_;
  $desc =~ s/\@\@\@/ /g;
  # Remove leading and trailing spaces
  $desc =~ s/^\s*:\s*//;
  $desc =~ s/\s*$//;
  return $desc;
}

sub parse_name_list( $ )
{
  my ($names) = @_;
  # Remove leading and trailing spaces
  $names =~ s/^\s*:\s*//;
  $names =~ s/\s*$//;
  $names =~ s/\s+(?:avec|et)\s+/, /i;
  my @list=split /(?:\s*,)+\s*/, $names;
  return @list;
}

sub get_detailed_fic( $$$ ) 
{
  my $id    = shift;
  my $prog  = shift;
  my $title = shift;
  my $nbretry = 0;
  $id =~ /fiche\('(\d+)'\)/ or die "expected fiche(x), got: $id";
  $id = $1;         
  my $FIC_FILE = new File::Temp(SUFFIX => '.xmltv' );
  debug_print("Calling sheet URL : " . $SHEET_URL . $id . "\n");

  # Get the current page
  while ( HTTP::Status::is_error(getstore($SHEET_URL . $id, $FIC_FILE->filename )) ) {
    sleep(1); $nbretry++;
    return if ($nbretry == 5 );
  }
  my $tfic = HTML::TreeBuilder->new;
  $tfic->store_comments(1);
  $tfic->parse_file( $FIC_FILE->filename );  
   
  # This page's title tag contains the program title without the sub-title. Use it to separate the two.
  my $ttitle;
  if ( $ttitle = $tfic->look_down('_tag', 'title') ) {
    my $htmltitle = $ttitle->as_text();
    $htmltitle =~ s/^Fiche Programme TV : //g;
    if ($title =~ s/^\Q$htmltitle\E\s+-\s+//) {
      $prog->{'title'} = [ [ tidy($htmltitle) ] ];
      $prog->{'sub-title'} = [ [ tidy($title) ] ];             
    }
  }

  # Get the duration and the year
  if ( my $tdesc = $tfic->look_down('_tag', 'td', 'bgcolor', '#F8F8F8') ) {
    if (my $img = $tdesc->look_down('_tag', 'img', 'alt', qr/^(Accord|Interdit)/)) {
      my $text=$img->attr('alt');
      my $rating;
      if ($text =~ /Accord parental souhaitable/i) {
        $rating="-10";
      } elsif ($text =~ /Accord parental indispensable/i) {
        $rating="-12";
      } elsif ($text =~ /Interdit aux moins 16 ans/i) {
        $rating="-16";
      } elsif ($text =~ /Interdit aux moins 18 ans/i) {
        $rating="-18";
      } else {
        warn "Unknown show rating [$text]\n";
      }
      if ($rating) {
        my $icon="http://telepoche.guidetele.com" . $img->attr('src');
        push @{$prog->{rating}}, [ $rating, "CSA", [ {src => $icon} ] ];
      }
    }

    debug_print "RAWDATA: " . tidy($tdesc->as_text()) . "\n";
    foreach my $field ( split(/\s+/, tidy($tdesc->as_text())) ) {
      # Set to lowercase for better color/b&w detection
      $field = lc($field);
      if ( $field =~ s/^(\d\d\d\d)$//i ) {
        $prog->{'date'} = $1;
      } elsif ( $field =~ s/^coul.*//i ) {
        $prog->{'video'}{colour} = 1;
      } elsif ( $field =~ s/^noir.*//i ) {
        $prog->{'video'}{colour} = 0;
      } elsif  ( $field =~ s%^16/9%%) {
        $prog->{'video'}{aspect} = "16:9";
      } elsif ( $field =~ s/^(st.r.o|Dolby)\s*//i) {
        my $stereo = $1;
        if ($stereo =~ /^st.r.o$/) {
          $prog->{'audio'}{stereo} = "stereo";
        } elsif ($stereo eq "Dolby") {
          $prog->{'audio'}{stereo} = "dolby";       
        }
      } elsif ($field =~ s/(\d+)h(\d+)//) {
        my ($hour, $min) = ($1, $2);
        # guidetele.com is full of bugs ...
        $hour = $hour - 12 if ($hour >= 12);
        my $duration=($hour * 3600) + ($min * 60);
        $prog->{'length'} = $duration if ($duration != 0);
      }
    }
  }

  # The actors list is really hard to identify and risks producing false
  # positives. Fortunately we know it follows a 'DISTRIBUTION' comment.
  # So we:
  # - locate the 'DISTRIBUTION' comment and identify what should be the
  #   first actor after that
  # - only set $actors_section to 1 when we are in the right area of the page.
  #   The rest of the time it is set to 0 before the actors section,
  #   and 2 after it.
  my $actors_section=0;
  my $first_actor;
  if (my $comment=$tfic->look_down('_tag', '~comment', 'text', qr/DISTRIBUTION/)) {
    my $sibling=$comment->right();
    if (!ref $sibling) {
      # $sibling is a string, what we want is the next HTML element
      $sibling=($comment->parent()->content_list())[$comment->pindex()+2];
    }
    if (defined $sibling) {
      $first_actor=$sibling->look_down('_tag', 'span', 'class', 'noir11');
    }
  }

  # Now get descriptions, summary, advices, actors and director
  # These are represented as <span class='noir11'> / <span class='noir11r'>
  # pairs.
  my ($resume, $histoire, $avis);
  foreach my $span ($tfic->look_down('_tag', 'span', 'class', 'noir11')) {
    my $sibling=$span->right();
    next if (!defined $sibling);

    my $value="";
    if (!ref $sibling) {
      # $sibling is a string, what we want is the next HTML element
      $value=$sibling;
      $sibling=($span->parent()->content_list())[$span->pindex()+2];
      next if (!defined $sibling);
    }
    if ($sibling->attr('_tag') ne "span" or
        $sibling->attr('class') ne "noir11r") {
      # Not a valid value span tag
      next;
    }
    $value.=$sibling->as_text();
    my $name=$span->as_text();

    if ($name =~ /^Titre original/i) {
      # FIXME: Still in the works...
      ;
    } elsif ($name =~ /^R.*alisateur/i) {
      push @{$prog->{credits}{director}}, parse_name_list(tidy($value));
    } elsif ($name =~ /^Pr.*sentateur/i) {
      my @presenter = parse_name_list(tidy($value));
      if ( $#presenter != 1 ) {
      	push @{$prog->{credits}{presenter}}, @presenter ;
      } 
    } elsif ($name =~ /^Sc.*nariste/i || $name =~ /^Sc.*nario/i) {
      push @{$prog->{credits}{writer}}, parse_name_list(tidy($value));
    } elsif ($name =~ /Musique/i) {
      # No xmltv field for this
      ;
    } elsif ($name eq "HISTOIRE") {
      $histoire = text_cleanup(tidy($value));
      $actors_section=2;
    } elsif ($name eq "RESUME") {
      $resume = text_cleanup(tidy($value));
      $actors_section=2;
    } elsif ($name eq "AVIS") {
      $avis = text_cleanup(tidy($value));
      $actors_section=2;
    } elsif ($actors_section == 1 or
             ($actors_section == 0 and defined $first_actor and $span eq $first_actor)) {
      my $actorname = text_cleanup(tidy($name));
      if ( $actorname ne "" ) {
        push @{$prog->{credits}{actor}}, $actorname;
      }
      $actors_section=1;
    }
  }

  # RESUME is the main definition, HISTOIRE is shorter.
  foreach ($resume, $histoire) {
    push @{$prog->{desc}}, [ $_, $LANG ] if defined and length;
  }
  # Add AVIS to the main description, or make a new desc for it if there are none.
  if (defined $avis and length($avis) ) {
    if ($prog->{desc}) {
      $prog->{desc}->[0]->[0] .= " Critique : " . $avis;
    } else {
      push @{$prog->{desc}}, [ $avis, $LANG ];
    }
  }

  $tfic->delete(); undef $tfic;
}

$ tv_grab_fr --configure

Le paramétrage ci-dessus produit un fichier tv_grab_fr.conf qui contient les chaînes sélectionnées.

La commande manuelle suivante permet d'indiquer un certain nombre d'informations pour chacune des chaînes préalablement choisies

Pour configurer xmltv tu tapes donc  tv_grab_fr -- configure.
Il te crée un fichier dans ~/.xmltv/tv_grab_fr.conf, puis on le lie
sudo ln -s ~/.xmltv/tv_grab_fr.conf ~/.mythtv/csat.xmltv



puis un
mythfilldatabase --graboptions "--perdays"

l'option
Code :

--graboptions "--perdays"

peut étre indiquée dans la configuration de mythfrontend (option à passer à mythfilldatabase).

Dernière modification par oblooblo2000 (Le 18/10/2007, à 00:41)

Hors ligne

#22 Le 25/10/2007, à 23:57

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

je continue et grace a ce site:

http://mythtv-fr.info/index.php?file=Forum&page=viewtopic&forum_id=4&thread_id=121

je scan les dernieres chaines:

- plutôt que de me renseigner sur les caractéristiques de chaque canal j'ai installé un paquet "dvb-utils"
http://www.linuxtv.org/wiki/index.php/LinuxTV_dvb-apps et
http://sourceforge.net/projects/dvbtools/

2 methodes:
apt-get install dvb-utils

soit
wget http://www.linuxtv.org/download/dvb/linuxtv-dvb-apps-1.1.1.tar.gz
uncompresse
cd to the top directory level of the uncompressed sources; run 'make' and then 'sudo make install'

ou le recuperer ici:
http://packages.ubuntu.com/dapper/misc/dvb-utils

qui m'a permis de lancer la commande:

scan -v /usr/share/doc/dvb-utils/examples/scan/dvb-s/Astra-19.2E -l UNIVERSAL -a 0 | tee channels-22jan2007.conf


et sauvegarde la sortie dans un fichier
- ayant accès à un bouquet limité on peut soit même recréé un fichier "channels.conf" avec uniquement les chaînes qui intéressent


- au moment de scanner les chaînes lui indiquer le chemin vers votre fichier "~user/channels.conf"

Dernière modification par oblooblo2000 (Le 26/10/2007, à 00:12)

Hors ligne

#23 Le 28/11/2007, à 19:15

bellad

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

bonjour , et merci pour ce tuto
j'ai fait comme t'a dis , quand je fait insmod dvbloopback.ko
je n'ai pas de adapter1 dans /dev/dvb

pour info je suis sous linuxmce 704 , une nova-s , les drivers v4l (avec adapter0) et une graphique nvidia

quelqu'un peut il m'aider ?
merci

#24 Le 06/12/2007, à 23:46

oblooblo2000

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

salut,
a priori, si j'ai bien compris:
- tu as compiler dvbloopback.ko
- tu as un /dev/dvb/adptater0

lance tu la commande comme ca (avec le chemin absolu?? car sinon tu dois le mettre dans le path)
sudo insmod /script/mythtv/sasc/dvbloopback.ko

As tu des messages d'erreurs ?
As tu plusieurs cartes ?

@ +

Hors ligne

#25 Le 10/12/2007, à 17:32

bellad

Re : [resolu]feisty + mythtv + sasc-ng + infinity phoenix

salut, excuse du retard , j'ete avec linuxmce 704 et j'attends la 710. Du coup j'ai tout viré et je suis en train d'installé ubuntu 710 et ensuite je vais suivre ton exemple
je te tiendrai au courent
merci

Hors ligne