Author Topic: AH film file (*.ahf) search script  (Read 931 times)

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
AH film file (*.ahf) search script
« on: November 13, 2007, 04:14:59 PM »
Hi

My plan is to make a small film and I started to searching a *.ahf material for it from //films folder. I knew about which terrain I was after or with who I was flying with so, easy to search, right? Well, no.

Process was too slow for my taste so, I coded a *.ahf file search script:
http://www.warezhouze.1g.fi/Here/AH/vids/AHF%20search_0a1.py


The script requirements and installation
1. This script require the python programming language installation: http://www.python.org/
2. The script must locate to the /HTC/Aces High II/films/ folder
3. User need to open the 'AHF_search_0a1.py' file with notepad( or similar) and define the paths to the /films folder and to the notepad.exe program.



How to run the script and view the result?
1. Open the /films folder and start the script by double clicking it



2. Give a search parameter: map name or player name and hit enter. The search process takes some time due file by file, line by line search.



3. The script will create the "AHF_[your search parameter].txt" report file to the //films folder and open it with Notepad for viewing.



Thats it so far.

Later maybe a basic AND / OR search strings, AHF_*.txt report with .ahf file size & date data and 'Save As..' functions.

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
AH film file (*.ahf) search script
« Reply #1 on: November 13, 2007, 04:16:07 PM »
The code is visible below, if you are worry about spyware etc stuff

# The .ahf file search ver. 0a1 by Xjazz
# The python installation is needed to run this script
# [url]http://www.python.org/[/url]

# Place this script to the AH films folder

# DEFINE YOUR DRIVE AND PATH TO AH FILM FOLDER!!!
path = 'c:/Program Files/HTC/Aces High II/films/'
# DEFINE YOUR DRIVE AND PATH TO THE NOTEPAD.EXE!!!
nppath ='c:/windows/notepad.exe'

import os, sys
FILM_LIST=[]
REPORT=''

def get_ahfFiles(NAME,path, tex=''):  
  arqs = os.listdir(path)
  for a in arqs:
    if a.endswith('.ahf'):
      find_name(NAME,path,a)
  report_file(NAME,FILM_LIST)

def find_name(NAME,path, a):
  ahfread = open((path+a),'rb')
  ahflines = ahfread.readlines()
  ahfread.close()
 
  for l in ahflines:
    if l.find(NAME)!=-1:
      try:
        if FILM_LIST.index(a) is False:
          pass
      except ValueError:
          FILM_LIST.append(a)
 
def report_file(NAME,FILM_LIST):
  fname = ('AHF_'+NAME)+'.txt'
  REPORT = path+fname
  rfile = open(fname,'w')
  fname = fname+'\n'
  sps = 'The search parameter was: '+NAME+'. '+(str(len(FILM_LIST)))+' found.' +'\n'+'\n'
  rfile.write(sps)

  for f in FILM_LIST:
    f = f+'\n'
    rfile.write(f)  
  rfile.close()
  os.spawnl(os.P_NOWAIT, nppath, 'notepad.exe',REPORT)
 
def name_chk():
  NAME=''
  while len(NAME.lstrip(' ')) < 2:
    NAME = raw_input("Give a searh parameter or write 'exit' to exit: ")
    if NAME == 'exit':
      sys.exit()
  get_ahfFiles(NAME, path)
 
# Start
name_chk()

Offline Gianlupo

  • Platinum Member
  • ******
  • Posts: 5154
AH film file (*.ahf) search script
« Reply #2 on: November 13, 2007, 04:28:52 PM »
Nice idea, J! I usually re name my film to ID them and remember what's in them, but, of course, I can't list everything, so this script is very welcome. I'll try it right away! :)

EDIT: Ok, tried it, it works nicely. Just one question: does it search even in subfolders?
« Last Edit: November 13, 2007, 05:01:41 PM by Gianlupo »
Live to fly, fly to live!

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
AH film file (*.ahf) search script
« Reply #3 on: November 14, 2007, 11:34:39 AM »
Quote
Originally posted by Gianlupo
Nice idea, J! I usually re name my film to ID them and remember what's in them, but, of course, I can't list everything, so this script is very welcome. I'll try it right away! :)

EDIT: Ok, tried it, it works nicely. Just one question: does it search even in subfolders?


Hi G

Good to hear it works for you :)

Current script only works in /films folder and ignore all sub-folders. I will look after this issue.

Offline Gianlupo

  • Platinum Member
  • ******
  • Posts: 5154
AH film file (*.ahf) search script
« Reply #4 on: November 15, 2007, 03:24:34 AM »
Rgr that! Thank you, it would be great if it could search in any directory and sub directory. I usually store my videos in different folders. :)
Live to fly, fly to live!

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
AH film file (*.ahf) search script
« Reply #5 on: December 03, 2007, 04:10:43 PM »
Quote
Originally posted by Gianlupo
Rgr that! Thank you, it would be great if it could search in any directory and sub directory. I usually store my videos in different folders. :)


Hi G!

Here it is
http://www.warezhouze.1g.fi/Here/AH/vids/AHF%20search_1v0.py

This version DO NOT require any path settings. Just paste script to your film root directory and run it just with double click.

The script will ask:
- The case sensitive search parameter, which must be at least 3 character long.
- Subdir search or not.

At the end your windows default text editor will open the search result report.

Offline Kermit de frog

  • Gold Member
  • *****
  • Posts: 3695
      • LGM Films
AH film file (*.ahf) search script
« Reply #6 on: December 03, 2007, 08:25:42 PM »
That website looks like something I've seen before years ago.  Something about that "w" word seems to be ringing bells when I used to search for applications that were "free".

:noid
Time's fun when you're having flies.

Offline Xjazz

  • Gold Member
  • *****
  • Posts: 2653
AH film file (*.ahf) search script
« Reply #7 on: December 03, 2007, 11:23:25 PM »
Quote
Originally posted by Kermit de frog
That website looks like something I've seen before years ago.  Something about that "w" word seems to be ringing bells when I used to search for applications that were "free".

:noid


:)

The site provider is well know company, Nebula Oy (http://www.nebula.fi), and '1G' site is their one product (http://www.1g.fi). User can choose  site name she/he want, within availability. I was looking after the 'www.warehouse.1g.fi' or finnish version 'www.varasto.1g.fi' names but those were taken already. So, thats why warezhouze...

Offline Gianlupo

  • Platinum Member
  • ******
  • Posts: 5154
AH film file (*.ahf) search script
« Reply #8 on: December 04, 2007, 02:58:56 AM »
Thank you, J!

It works great! :)
Live to fly, fly to live!