AutoHotkey Community

It is currently May 27th, 2012, 2:20 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: November 17th, 2007, 10:52 am 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
for FIREFOX > reads / copy / rename cache >> xy.mp3 xy.flv
--------------------------------------------------------------
while surfing watching video (wait scrollbar should be 100%)
or listening music
like > youtube metacafe ehrensenf ... etc

the files are downloaded already to CACHE

for MS-IE youtube see:
http://www.autohotkey.com/forum/topic25556.html


Image


Code:
MODIFIED=20071117


;-------------------------------------------------------------------
/*

      for FIREFOX > reads / copy / rename cache >> xy.mp3   xy.flv
      --------------------------------------------------------------
      while surfing watching video (wait scrollbar should be 100%)
      or listening music
      like > youtube metacafe ehrensenf  ... etc

      the files are downloaded already to CACHE



;     here the end of your script which you every day use
       or make a button

;     copies and rename CACHE to your New Folder when close
;     before you clear cache in the firefox browser


;      http://www.autohotkey.net/~garry/FireFox_Cache01.jpg

GuiClose:
gosub,Firefoxcache
ExitApp
*/
;-------------------------------------------------------------


;-----------------------------------------------
FIREFOXCACHE:
;Gui,1:submit,nohide


;------------------------------- your correct path here -----------------------------------------------------------------------------
AA2=C:\Dokumente und Einstellungen\Administrator\Lokale Einstellungen\Anwendungsdaten\Mozilla\Firefox\Profiles\kjf29nqa.default\Cache

;------------------------------------------------------------------------------------------------------------------------------------

ifnotexist,%AA2%
  {
  msgbox,Search for the correct path from your FirefoxCache like :`n C:\......\Firefox\Profiles\kjf29nqa.default\Cache
  return
  }

;----------------------------------------------------------------------------
R3CACHE=C:\_REC_FIREFOX_CACHE     ;copied video /music found here as mp3/flv
ifnotexist,%R3CACHE%
FileCreateDir,%R3CACHE%
;----------------------------------------------------------------------------


;--------------------------------
  I7=0
  Loop %AA2%\*.*
     {
      S1=
      S2=
      exten=
      LFP=%A_LoopFileLongPath%
      LFN=%A_LoopFilename%
      stringmid,LFN1,LFN,1,1
      if LFN1=_
      continue

      FileReadLine,VAR1,%LFP%,1
      stringmid,S1,VAR1,1,3
      if S1=FLV
        {
        exten=flv
        }

      FileReadLine,VAR2,%LFP%,1
      stringmid,S2,VAR2,1,3
      if S2=ID3
        {
        exten=mp3
        }

      if (exten="flv" OR exten="mp3")
      goto,skip02
        else
        continue

      SKIP02:
          {
          new=%LFN%.%exten%
          I7++
          FileCopy,%LFP%,%R3CACHE%\%new%,1
          }
      }

if I7>0
   {
   run,%R3CACHE%     ;opens folder if found
   return
   }

else
  {
  msgbox, No files mp3/flv found in FIREFOX CACHE:`n%AA2%
  return
  }
return
;-----------------------------------




===========================================
2nd script
-renames MP3 files with the right name
-move every 2 minutes from cache

Code:
MODIFIED=20081204


;============================================================

;   While listening/watching music/video with FireFox...
;      downloads video  (flv)  and music (mp3)
;      rename mp3 files to the correct name

;=============================================================
 


/*
;--------- MOZILLA FIREFOX CACHE WHERE IS IT  (?) ---------------------------
typein in browser mozilla FireFox:

about:cache?device=disk

see follow:
Cache Directory:  (example)
C:\Dokumente und Einstellungen\Administrator\Lokale Einstellungen\Anwendungsdaten\Mozilla\Firefox\Profiles\kkik01gb.default\Cache
*/
;==================================================================================================================================


;----- path Mozilla Cache (see above) ---
AA2=C:\Dokumente und Einstellungen\Administrator\Lokale Einstellungen\Anwendungsdaten\Mozilla\Firefox\Profiles\kkik01gb.default\Cache

R3CACHE1=C:\_REC_FIREFOX_CACHE1     ;copies found mp3/flv here
ifnotexist,%R3CACHE1%
FileCreateDir,%R3CACHE1%


R3CACHE2=C:\_REC_FIREFOX_CACHE2     ;move renamed mp3/flv here
ifnotexist,%R3CACHE2%
FileCreateDir,%R3CACHE2%



Gui,2:Color,black
Gui,2:Font,  S10 CDefault , Lucida Console
Gui,2:Add,Button,  x10    y10    h20  w100   gBEE           ,MuviBee
;Gui,2:Add,Button,  x120   y10    h20  w100   gSEEQPOD       ,SeeqPod
Gui,2:Add,Button,  x120   y10    h20  w100   gSearchPlaylist ,SearchPL
Gui,2:Add,Button,  x250   y10    h20  w100   gFIREFOXCACHE   ,START

;Gui,2:Add,Button,  x10    y40    h20  w100   gCLRCACHE    ,CLR-MOZ
;Gui,2:Add,Button,  x120   y40    h20  w100   gCLRCACHE1   ,CLR-1
;Gui,2:Add,Button,  x250   y40    h20  w100   gCLRCACHE2   ,CLR-2

Gui,2:Add,Button,  x10    y70    h20  w100   gCLRCACHEX    ,OPEN-MOZ
Gui,2:Add,Button,  x120   y70    h20  w100   gCLRCACHEX1   ,OPEN-1
Gui,2:Add,Button,  x250   y70    h20  w100   gCLRCACHEX2   ,OPEN-2

Gui,2:Show,        x0    y0     h100  w380 ,FIREFOXCACHE
gosub,Firefoxcache
settimer,AAS1,120000     ; copy every 2 minutes
return
;---------------------------------------------------------------------------

/*
CLRCACHE:
Filerecycle,%AA2%\*.*
return

CLRCACHE1:
Filerecycle,%R3CACHE1%\*.*
return

CLRCACHE2:
Filerecycle,%R3CACHE2%\*.*
return
*/


CLRCACHEX:
Run,%AA2%
return

CLRCACHEX1:
Run,%R3CACHE1%
return

CLRCACHEX2:
Run,%R3CACHE2%
return


2Guiclose:
;Filerecycle,%R3CACHE1%\*.*
exitapp




BEE:
run,http://www.muvibee.com/watch/?q=jim+reeves&t=all
return

SEEQPOD:
run,http://www.seeqpod.com/search/
return

SEARCHPLAYLIST:
;run,http://searchbeta.playlist.com/tracks#jim`%20reeves
run,http://search.playlist.com/tracks/jim`%20reeves
return


;--------------------------------------------------------
FIREFOXCACHE:
FFC=1
AAS1:
Gui,2:submit,nohide

;---------- copy the ORIGINAL FIREFOX CACHE FLV/MP3 TO %R3CACHE1%  --------------
  I7=0
  Loop %AA2%\*.*
     {
      S1=
      S2=
      exten=
      LFP=%A_LoopFileLongPath%
      LFN=%A_LoopFilename%
      stringmid,LFN1,LFN,1,1
      if LFN1=_
      continue

      FileReadLine,VAR1,%LFP%,1
      stringmid,S1,VAR1,1,3
      if S1=FLV
        {
        exten=flv
        }

      FileReadLine,VAR2,%LFP%,1
      stringmid,S2,VAR2,1,3
      if S2=ID3
        {
        exten=mp3
        }

      if (exten="flv" OR exten="mp3")
      goto,skip07
        else
        continue

      SKIP07:
          {
          new=%LFN%.%exten%
          I7++
          FileCopy,%LFP%,%R3CACHE1%\%new%,1
          }
      }
;---------- END of copy (dont move ) the ORIGINAL FIREFOX CACHE TO %R3CACHE1%  --------------




;-------------------- move only flv to %R3CACHE2%  ------------------------
Loop,%R3CACHE1%\*.flv
     {
     IFLV++
     SplitPath,A_LoopFileLongPath,name,dir,ext,name_no_ext,drive
     FileMove,%A_LoopFileLongPath%,%R3CACHE2%\%name%,1
     }
;------------------- END copy only flv --------------------------------------
;----------------------------------------------------------------------------




;----------------------- READ %R3CACHE1%  MP3  and retrieve TAG --------------------
Loop,%R3CACHE1%\*.mp3
{
  SplitPath,A_LoopFileLongPath,name,dir,ext,name_no_ext,drive
   file=%A_LoopFileLongPath%
  title=
  performer=
  Gosub,READTAGS     ;>>>>>>>
  Gosub,RETRIEVE     ;>>>>>>>
}

if FFC=1
  {
  run,%R3CACHE2%                             ;open Folder
  FFC=0
  }

return
;------------------------------------------ END -------------------------------------




;---------------------  RETRIEVE MP3 and move  to %R3CACHE2%  --------------------------
RETRIEVE:

If title=
   {
   SplitPath,File, name2, dir2, ext2, name_no_ext2, drive2
   title=TEST_%name_no_ext2%
   Filemove,%FILE%,%R3CACHE2%\%TITLE%.%ext%,1        ;rename XXX.mp3  to TEST_%title%
   Return
   }


;---------- remove special characters --
REMOVECHR3:

new2=
Loop,Parse,TITLE
         {
         A:=(Asc(A_LoopField))
         B:=chr(a)
         if (B="_" OR B=" ")     ;allow _space   autotrim,off
         Goto,SKIP6
         if ((a<48 or a>57) AND A<65 OR A>90 AND A<97 OR A>122)
         continue
         SKIP6:
         new2=%new2%%b%
         }

  TITLE=%new2%

  ;msgbox,PERFORMER=%PERFORMER%

   Filemove,%FILE%,%R3CACHE2%\%TITLE%.%ext%,1                ;rename XXX.mp3  to %title%
return
;--------------------------------------------------------------








;-------------- READ TAG ONLY MP3 ----------------------------------------
;file=test01.mp3
READTAGS:
;;;;;;; HEADER ;;;;;;;
res:=BinRead(file,data,3,0)
fileidentifier:=DeHexify(data)

res:=BinRead(file,data,1,3)
majorversion:=data+0
res:=BinRead(file,data,1,4)
revisionnumber:=data+0
version=%majorversion%.%revisionnumber%

res:=BinRead(file,data,1,5)
flags=0x%data%
Transform,unsync,BitAnd,%flags%,256
Transform,extheader,BitAnd,%flags%,128
Transform,experimentalid,BitAnd,%flags%,64
Transform,footer,BitAnd,%flags%,32

res:=BinRead(file,data,2,8)
size=0x%data%
size+=0

extheaderpos:=10

;;;;;;; EXTENDEDHEADER ;;;;;;;

If extendedheader=1
{
  res:=BinRead(file,data,4,extheaderpos)
  frameid:=DeHexify(data)

  res:=BinRead(file,data,4,extheaderpos+4)
  extheadersize=0x%data%
  extheadersize+=10
  frameheaderpos:=extheaderpos+extheadersize
}
Else
  frameheaderpos:=extheaderpos

;;;;;;; FRAMES ;;;;;;;

Loop
{
;;;;;;; FRAMEHEADER ;;;;;;;

  res:=BinRead(file,data,4,frameheaderpos)
  frameid:=DeHexify(data)

  res:=BinRead(file,data,4,frameheaderpos+4)
  framesize=0x%data%
  framesize+=0

  res:=BinRead(file,data,1,frameheaderpos+8)
  flaga:=data
  res:=BinRead(file,data,1,frameheaderpos+9)
  flagb:=data

  If frameid=
    Break

;  TIT2: title
;  USLT: lyrics
;  TPE1: performer

  If (frameid="TPE1" Or frameid="TIT2" Or frameid="USLT")
  {

    framepos:=frameheaderpos+10 ;frameheadersize=10

;;;;;;; FRAME ;;;;;;;

    If framesize>0
    {
      res:=BinRead(file,data,framesize,framepos)
      frametext:=DeHexify(data)

      If (frameid="TPE1")
        performer:=frametext
      Else
      If (frameid="TIT2")
        title:=frametext
      Else
      If (frameid="USLT")
        StringTrimLeft,lyrics,frametext,3
    }
  }
  frameheaderpos:=frameheaderpos+framesize+10 ;frameheadersize=10
  If (frameheaderpos>=size)
    Break
}
;MsgBox,0,id3v2,Performer:%performer% `nTitle:%title% `nLyrics:`n%lyrics%
Return

DeHexify(x)
{
   StringLen,len,x
   len:=len/2
   string=
   Loop,%len%
   {
      StringLeft,hex,x,2
      hex=0x%hex%
      Transform,y,Chr,%hex%
      string:=string y
      StringTrimLeft,x,x,2
   }
   Return,string
}


;By lazlo at http://www.autohotkey.com/forum/viewtopic.php?t=4546
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BinWrite ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|  - Open binary file
|  - (Over)Write n bytes (n = 0: all)
|  - From offset (offset < 0: counted from end)
|  - Close file
|  data -> file[offset + 0..n-1], rest of file unchanged
|  Return #bytes actually written
*/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

BinWrite(file, data, n=0, offset=0)
{
   ; Open file for WRITE (0x40..), OPEN_ALWAYS (4): creates only if it does not exists
   h := DllCall("CreateFile","str",file,"Uint",0x40000000,"Uint",0,"UInt",0,"UInt",4,"Uint",0,"UInt",0)
   IfEqual h,-1, SetEnv, ErrorLevel, -1
   IfNotEqual ErrorLevel,0,Return,0 ; couldn't create the file

   m = 0                            ; seek to offset
   IfLess offset,0, SetEnv,m,2
   r := DllCall("SetFilePointerEx","Uint",h,"Int64",offset,"UInt *",p,"Int",m)
   IfEqual r,0, SetEnv, ErrorLevel, -3
   IfNotEqual ErrorLevel,0, {
      t = %ErrorLevel%              ; save ErrorLevel to be returned
      DllCall("CloseHandle", "Uint", h)
      ErrorLevel = %t%              ; return seek error
      Return 0
   }

   TotalWritten = 0
   m := Ceil(StrLen(data)/2)
   If (n <= 0 or n > m)
       n := m
   Loop %n%
   {
      StringLeft c, data, 2         ; extract next byte
      StringTrimLeft data, data, 2  ; remove  used byte
      c = 0x%c%                     ; make it number
      result := DllCall("WriteFile","UInt",h,"UChar *",c,"UInt",1,"UInt *",Written,"UInt",0)
      TotalWritten += Written       ; count written
      if (!result or Written < 1 or ErrorLevel)
         break
   }

   IfNotEqual ErrorLevel,0, SetEnv,t,%ErrorLevel%

   h := DllCall("CloseHandle", "Uint", h)
   IfEqual h,-1, SetEnv, ErrorLevel, -2
   IfNotEqual t,,SetEnv, ErrorLevel, %t%

   Return TotalWritten
}

/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BinRead ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|  - Open binary file
|  - Read n bytes (n = 0: all)
|  - From offset (offset < 0: counted from end)
|  - Close file
|  data (replaced) <- file[offset + 0..n-1]
|  Return #bytes actually read
*/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

BinRead(file, ByRef data, n=0, offset=0)
{
   h := DllCall("CreateFile","Str",file,"Uint",0x80000000,"Uint",3,"UInt",0,"UInt",3,"Uint",0,"UInt",0)
   IfEqual h,-1, SetEnv, ErrorLevel, -1
   IfNotEqual ErrorLevel,0,Return,0 ; couldn't open the file

   m = 0                            ; seek to offset
   IfLess offset,0, SetEnv,m,2
   r := DllCall("SetFilePointerEx","Uint",h,"Int64",offset,"UInt *",p,"Int",m)
   IfEqual r,0, SetEnv, ErrorLevel, -3
   IfNotEqual ErrorLevel,0, {
      t = %ErrorLevel%              ; save ErrorLevel to be returned
      DllCall("CloseHandle", "Uint", h)
      ErrorLevel = %t%              ; return seek error
      Return 0
   }

   TotalRead = 0
   data =
   IfEqual n,0, SetEnv n,0xffffffff ; almost infinite

   format = %A_FormatInteger%       ; save original integer format
   SetFormat Integer, Hex           ; for converting bytes to hex

   Loop %n%
   {
      result := DllCall("ReadFile","UInt",h,"UChar *",c,"UInt",1,"UInt *",Read,"UInt",0)
      if (!result or Read < 1 or ErrorLevel)
         break
      TotalRead += Read             ; count read
      c += 0                        ; convert to hex
      StringTrimLeft c, c, 2        ; remove 0x
      c = 0%c%                      ; pad left with 0
      StringRight c, c, 2           ; always 2 digits
      data = %data%%c%              ; append 2 hex digits
   }

   IfNotEqual ErrorLevel,0, SetEnv,t,%ErrorLevel%

   h := DllCall("CloseHandle", "Uint", h)
   IfEqual h,-1, SetEnv, ErrorLevel, -2
   IfNotEqual t,,SetEnv, ErrorLevel, %t%

   SetFormat Integer, %format%      ; restore original format
   Totalread += 0                   ; convert to original format
   Return TotalRead
}
;----------------- END MP3 TAG READER     -----------------------------------------------------------

;Download Youtube (MP4):
;http://www.autohotkey.com/forum/topic34932.html
;http://www.autohotkey.com/forum/topic25694.html


Last edited by garry on December 4th, 2008, 8:32 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: nice
PostPosted: November 17th, 2007, 10:53 am 
Offline

Joined: November 12th, 2007, 10:18 am
Posts: 142
Location: South Australia
Wow this is pretty impressive.
Keep up with the good work!

_________________
Image
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2010, 11:52 pm 
Offline

Joined: May 8th, 2008, 2:58 pm
Posts: 39
Location: C:\ESTONIA\adavere\RIST.rar
nice script but how get .mp4 videos from cache ?

_________________
Keegi Siin ka Eestlane? :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 6:14 am 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
here a script for youtube, get best quality
http://www.autohotkey.com/forum/topic34932.html


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot] and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group