Gå til innhold

Noen som kunne laget et lite skript til meg


Anbefalte innlegg

Hei

 

Lurer på om noen kunne laget et lite skript til meg (eller lært meg hvordan man gjør, men har ikke noe spesiell erfaring med programering).

 

Skriptet skal være til Samurize for å vise "Visste du at..." linjen som er nederst på www.startsiden.no og kunne vise den på desktopen. Slikt som tv skriptet funker.

Takk

 

Edit: Jeg plasserte dette innlegget sikker på feil plassering, så det er bare til å flytte det hvis du får lyst.

Endret av xanonymx
Lenke til kommentar
Videoannonse
Annonse
Gjest Slettet-aNZFa3
Hei

 

Lurer på om noen kunne laget et lite skript til meg (eller lært meg hvordan man gjør, men har ikke noe spesiell erfaring med programering).

 

Skriptet skal være til Samurize for å vise "Visste du at..." linjen som er nederst på www.startsiden.no og kunne vise den på desktopen. Slikt som tv skriptet funker.

Takk

 

Edit: Jeg plasserte dette innlegget sikker på feil plassering, så det er bare til å flytte det hvis du får lyst.

7564228[/snapback]

 

ehh,og hvor har du tenkt til å taste inn scripten?? da må du nok omprogrammere Windows'en, Mac'en, Linux'en eller hva du bruker

Lenke til kommentar

Men er det noen som kan hjelpe meg. Jeg tror ikke det er så mye arbeid med å lage et slikt script. Men jeg kan det jo ikke så jeg er ikke sikker.

Jeg skulle nå ønske at jeg kunne programert det selv. Så hvis noen vet om en side som er om å lære å programmere så hadde det hvert fint å fått vite om den. Men jeg er nødt til å ha det på norsk i så fall. Jeg orker ikke å lese så mye på engelsk.

Lenke til kommentar
Men er det noen som kan hjelpe meg. Jeg tror ikke det er så mye arbeid med å lage et slikt script. Men jeg kan det jo ikke så jeg er ikke sikker.

Jeg skulle nå ønske at jeg kunne programert det selv. Så hvis noen vet om en side som er om å lære å programmere så hadde det hvert fint å fått vite om den. Men jeg er nødt til å ha det på norsk i så fall. Jeg orker ikke å lese så mye på engelsk.

7596035[/snapback]

Ånei, men da er du nok lost. :)

Lenke til kommentar

Det var akkurat det. Det er derfor at jeg spør om noen kan lage det for meg. Grunnen til at jeg ikke tror det blir så stort er fordi er at tv skriptet ikke er så stort, hvis du tenker på at det viser for flere kanaler og til forskjellige tider.

 

Tv skriptet (endel av dette er jo bare forklaring, så selve programmerings delen er ikke så stor, noe som du sikkert klarer å se selv):

Klikk for å se/fjerne innholdet nedenfor
' NorskTV With Links Support (by Mythril)

'

' Based on UKTV v3.0 With Link Support (by Fiendish1)

'

' Updates:

'      1.1:    - Fixed a bug where the programs weren't always placed in the right channel

'              - Updated the channel list

'  1.0: - No real change, but since it seems that it shouldn't be any problems with the

'      script now, I'm releasing it as a final version!

'  0.81: - Channels that are not chosen, will be ignored!

'  0.8: - Changed the GetURL string, now the schedule should be correct after midnight.

'    - Changed the script so it's a little easier to change the order of channels.

'    - Removed the note about link support in Samurize, because it's not useful to

'      read several lines anyway after I added the program progress.

'  0.43: Changed the program info links, they should work now.

'  0.41: sol.no changed its layout, so I've updated the script to work with the new layout

'  0.4: Added progress bars for the currently running show.

'

' This script creates a textfile (NorskTV.txt) that can be read in via TextFile Meters. The

' textfile (NorskTV.txt) is normally created in the Samurize folder.

'

' Usage Instructions:

'

' 1. Copy "norsktv.vbs" into your Samurize Scripts folder.

' 2. If you wish, you may change the options under CONFIG SECTION

'  Specifically, if you want to change the channels that are shown, follow the instructions

'  in the config section!

' 2. Add an active script to your Samurize Config and select "norsktv.vbs"

'    Select the RefreshData function, set it to run when you want (e.g. every 10 mins)

' 3. Add a Text File Meter and point it to the NorskTV.txt file (normally in your Samurize Folder)

'    Choose which lines you want to read in. The format of the Textfile is as follows:

' Line 1 - TV3

' Line 2 - Running program

' Line 3 - Progress of running program (0-100%)

' Line 4&5 - Next two programs

' The following lines follow the same patterns. Check the config section to change the order of

' programs if you wish.

'

' NOTE: This script will take some time to run, because it downloads a large page from the internet.

'  Be patient!

'

'  ** CONFIG SECTION **

'

' 0 = Links off

' 1 = Links to webpage

LinkMode = 1

 

' The text below will be shown when no programs are available

NoProgsText = "Ingen programmer før imorgen"

 

' The variable below defines which programs should be first and what order they should be stored

' in NorskTV!

MyChannels = Array( "TV3", "TVN2", "TV2", "NRK1", "NRK2", "ZTV", "DISCOVERY" )

 

' The channel names you can use are (in alphabetical order):

'  3SAT

'  ANIMAL

'  BBC-PRIME, BBC-WORLD

'  CARTOON, CNBC, CNBCNATGEO, CPLFILM2, CANAL+, CPLFILM1, CNN, CLUB

'  CPLCMORE, CPLSPORT

'  DISNEY, DISCOVERY, D_SCI-TREK, DSF, D_CIVILISATION, D_TRAVEL, DW

'  DR1, DR2

'  EXTREME, EUROSPORT

'  HALLMARK

'  JETIX

'  KANAL5

'  MTV

'  NRK1, NRK2, NICKELODEON, NATGEO

'  PRO7

'  RTL, RTL2, REALITY

'  SVT1, SVT2, STAR, SHOWTIME, SAT1, SKYNEWS, SKYNATGEO

'  TV2, TV2X, TVN2, TV4, TV3, TV3_DK, TV3_SE, TV3PLDAN

'  TCMCARTOON, TOON DISNEY, TV2_DK, TRAVEL, TV6, TV8, TV5FRANCE

'  TV1000, TV1000A, TV1000C, TV1000F, TV1000N, TCM, THE VOICE

'  VH1, VIASATHIST, VIASATEXPL, VIASATSPORT, VIASPO2, VIASPO3

'  ZTV, ZTV_SE

'

' The names have to be written exactly as specified here, or the script may not recognize it!

' Hopefully it's easy to see which name is which channel... If not it's probably best to just

' test them and see if they show the program you're expecting.

'

' If you can't find the channel you want, try going to:

' http://www.sol.no/underholdning/tv/guiden/...es=*&Channels=*

' Find the channel you want, and open up it's logo. The filename of the logo will be the

' channel name used in this script. (But uppercased and without the filetype. Example:

'    If the filename is tv3.gif, then the name used in the script will just be TV3.

' If there is no logo, but a name inside brackets, then the name will be that name. Ex:

'    For [Toon Disney] the name will be TOON DISNEY.

'

' If you change the order, you'll also have to change the config to reflect the new order.

' Make sure you run the script once in the config editor to create the new NorskTV.txt, so

' you'll see the channels you want when you change the TextFile meters to show your program.

 

' If you don't know VBScript:

' Make sure that all the channels are inside ""s, and that they have a , after each of them,

' except for the last channel! If not you'll get a script error when you run this script.

 

 

 

' ** CODE SECTION **

' You shouldn't need to change anything below here!

 

 

' The function for fetching the schedule. Sorry that this isn't commented very well...

Function RefreshData

Dim Channels, Chan

   

    ' Make sure we get the correct schedule.

    TheDate = Month(Date) & "%2F" & Day(Date) & "%2F" & Year(Date)

    If Hour(Time) < 5 Then

        PreDate = DateAdd( "D", -1, Date )

        TheDate = Month(PreDate) & "%2F" & Day(PreDate) & "%2F" & Year(PreDate)

    End If

    GetURL = "http://www.sol.no/underholdning/tv/guiden/index.cgi?StartTime=now&EndTime=2900&Categories=*&Channels=*&Date=" & TheDate & "&refreshing=" & Time

   

Set Channels = CreateObject("Scripting.Dictionary")

For Each Chan in MyChannels

  Channels.Add Chan, CreateObject("Scripting.Dictionary")

Next

 

Dim Http

 

Set Http = CreateObject("Microsoft.XMLhttp")

Http.Open "GET",GetURL,False

Http.Send

HtmlResult = BinToText(Http.ResponseBody, 35000)

Set Http = Nothing

ProgramDato = RemoveHTMLArtifacts( GetHTMLValue2("<tr bgcolor=""#999900""><td> </td><td colspan=""4""><b style=""font-size:12px; color:#ffffff;"">", "</b></td></tr>", htmlresult, 1) )

 

For Count = 1 To 1000

  RawText = GetHTMLValue2("<td bgcolor=""#999900""> </td><td><font face=""verdana,arial,helvetica"" size=""1""><b>", "</td></tr>", htmlresult, count)

       

  If RawText = "N/A" Then Exit For

 

  FixedText = RemoveHTMLArtifacts(RawText) & vbNewLine

  InfoArray = Split(FixedText, "¤")

 

  ChannelName = UCase( GetHTMLValue2("http://tvguide.sol.no/img/logos/", ".", RawText, 1) )

        If ChannelName = "N/A" Then

            ChannelName = UCase(GetHTMLValue2("[", "]", RawText, 1))

        End If

       

  ProgTime = InfoArray(0)

  ProgEndtime = InfoArray(3)

  ProgTitle = InfoArray(12) & InfoArray(13)

 

  ProgTitle = Trim( Replace(ProgTitle, "~", "'") )

  If LinkMode > 0 Then

  RawLink = GetHTMLValue2("<a href=""", """", RawText, 1 )

  If RawLink <> "N/A" Then

    ProgTitle = ProgTitle & "%l" & RawLink

  End If

  End If

 

  If Channels.Exists( ChannelName ) Then

            If Channels( ChannelName ).Count < 4 Then

                Channels( ChannelName ).Add Channels( ChannelName).Count, ProgTime & "-" & ProgEndTime & " - " & ProgTitle

                If Channels( ChannelName ).Count = 1 Then

                    ProgLength = TimeDifference(ProgTime, ProgEndtime)

                    ProgRun = TimeDifference( ProgTime, Time )

                    If ProgLength > 0 Then

                        ProgPercent = CInt( ProgRun * 100 / ProgLength )

                    Else

                        ProgPercent = 0

                    End If

                    Channels( ChannelName ).Add Channels( ChannelName).Count, ProgPercent

                End If

            End If

        End If

Next

 

Set fs=CreateObject("Scripting.FileSystemObject")

Set f=fs.CreateTextFile("NorskTV.txt",true)

Keys = Channels.Keys

Items = Channels.Items

For Num = 0 To Channels.Count - 1

  f.Write Keys( Num ) & vbNewLine

  If Items( Num ).Exists(0) Then

  f.Write Items( Num )(0) & vbNewLine

  Else

  f.Write NoProgsText & vbNewLine

  End If

  f.Write Items( Num )(1) & vbNewLine

  f.Write Items( Num )(2) & vbNewLine

  f.Write Items( Num )(3) & vbNewLine

Next

Set fs=Nothing

Set f=Nothing

 

RefreshData = ProgramDato & " " &  Time

End Function

 

Private Function TimeDifference( StartTime, EndTime )

Dim StartMinutes, EndMinutes

StartMinutes = Hour(StartTime)*60 + Minute( StartTime )

EndMinutes = Hour(EndTime)*60 + Minute( EndTime )

If StartMinutes > EndMinutes Then

  EndMinutes = EndMinutes + 24*60

End If

TimeDifference = EndMinutes - StartMinutes

End Function

 

Private Function GetHTMLValue2(LeftBound, RightBound, htmlresult, count)

  HtmlStart = InStr(HtmlResult, LeftBound) + Len(LeftBound)

HtmlEnd = InStr(HtmlStart, HtmlResult, RightBound)

 

For counter = 2 To count

  HtmlStart = InStr(HtmlEnd + Len(RightBound), HtmlResult, LeftBound) + Len(LeftBound)

  HtmlEnd = InStr(HtmlStart, HtmlResult, RightBound)

Next

 

  If HtmlStart > Len(LeftBound) AND HtmlEnd > 0 Then

  GetHTMLValue2 = Replace(Mid(HtmlResult, HtmlStart, HtmlEnd - HtmlStart ), " ", " ")

  Else

  GetHTMLValue2 = "N/A"

End If

End Function

 

Private Function BinToText(varBinData, intDataSizeInBytes)    ' as String

 

Const adFldLong = &H00000080

    Const adVarChar = 200

    Set objRS = CreateObject("ADODB.Recordset")

 

    objRS.Fields.Append "txt", adVarChar, intDataSizeInBytes, adFldLong

    objRS.Open

 

    objRS.AddNew

    objRS.Fields("txt").AppendChunk varBinData

    BinToText = objRS("txt").Value

 

    objRS.Close

    Set objRS = Nothing

End Function

 

Private function RemoveHTMLArtifacts(ByRef asHTML)

    Dim loRegExp' Regular Expression Object

   

    ' Create built In Regular Expression object

    Set loRegExp = New RegExp

    ' Set the pattern To look For HTML tags

    loRegExp.Pattern = "<[^>]*alt=""([^""]*)""[^>]*>"

   

    ' Return the original String stripped of HTML

    RemoveHTMLArtifacts = loRegExp.Replace(asHTML, "$1")

 

loRegExp.Pattern = "<[^>]*>"

loRegExp.Global = True

 

    RemoveHTMLArtifacts = loRegExp.Replace(RemoveHTMLArtifacts, "¤")

 

    loRegExp.Pattern = "\æ"

    RemoveHTMLArtifacts = loRegExp.Replace(RemoveHTMLArtifacts, "æ")

    loRegExp.Pattern = "\ø"

    RemoveHTMLArtifacts = loRegExp.Replace(RemoveHTMLArtifacts, "ø")

    loRegExp.Pattern = "\å"

    RemoveHTMLArtifacts = loRegExp.Replace(RemoveHTMLArtifacts, "å")

    loRegExp.Pattern = "\Æ"

    RemoveHTMLArtifacts = loRegExp.Replace(RemoveHTMLArtifacts, "Æ")

    loRegExp.Pattern = "\Ø"

    RemoveHTMLArtifacts = loRegExp.Replace(RemoveHTMLArtifacts, "Ø")

    loRegExp.Pattern = "\Å"

    RemoveHTMLArtifacts = loRegExp.Replace(RemoveHTMLArtifacts, "Å")

    ' Release object from memory

    Set loRegExp = Nothing

End function

Lenke til kommentar

Ingen vits i å finne opp kruttet på nytt, hva? :p

Last ned Generic HTTP Scanner her (direktelink).

Så er det sannsyneligvis noe ala dette du kan forandre til i toppen av scriptet:

SITE_URL	= "http://www.startsiden.no/"
PAGE_CHECK  = "<title>ABC Startsiden - Topp</title>"
FIRST_CHECK	= "<div class="row">"
END_CHECK	= "</div>"
FIRST_CHECK2	= "<strong>Visste du at...</strong> <i>"
END_CHECK2	= "</i></p>"
REMOVE_END_CHECK= "no"
USERNAME	= ""
PASSWORD	= ""
HTTP_METHOD	= "Get"
BULLET_ON_NEW_LINES = "- "
SEPERATOR	= vbCrLf & vbCrLf
REMOVE_NEWLINES	= "No"

Endret av LarsChh
Lenke til kommentar

- Gjør scriptfilen tilbake sånn som den var orginal, om du ikke har gjort det.

I samurize Config Editor:

- Høyreklikk -> Add Active Script

- På "select script" til høyre velger du GenericHttpScanner.vbs

- På "select function to run" til høyre velger du GetInfo

- Da får du opp en popup, og i den første skriver du da: http://www.startsiden.no/

- I den andre: <title>ABC Startsiden - Topp</title>

- I den tredje: <div class="row">

- I den fjerde: </div>

- I den femte: <strong>Visste du at...</strong> <i>

- I den sjette: </i></p>

- I den syvende: no

- I den åttende skriver du ingenting

- I den niende skriver du ingenting

- I den tiende: Get

- I den ellevte skriver du ingenting

- I den tolvte skriver du ingenting

- I den trettende: no

 

Dette gjorde jeg nettopp selv, og det fungerte utmerket. Så hvis det fortsatt blir noe feil, vet jeg ikke hva det er..

Endret av LarsChh
Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...