Difference between revisions of "TruxtonFileIO newurl"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This creates a new website visit record from a file in Truxton. It automatically associates the parent file and media identifiers used in the Location Table | Location table...")
 
Line 1: Line 1:
 
This creates a new website visit record from a file in Truxton.
 
This creates a new website visit record from a file in Truxton.
It automatically associates the parent file and media identifiers used in the [[Location Table | Location table.]]
+
It automatically associates the parent file and media identifiers used in the [[WebsiteVisit Table | URL table.]]
  
 
=Syntax=
 
=Syntax=

Revision as of 15:40, 21 May 2020

This creates a new website visit record from a file in Truxton. It automatically associates the parent file and media identifiers used in the URL table.

Syntax

object newurl();

Return value

A Website Visit object

Sample

import truxton

from datetime import datetime
from calendar import timegm

EPOCH_AS_FILETIME = 116444736000000000
HUNDREDS_OF_NANOSECONDS = 10000000

def date_to_filetime(dt):
  return EPOCH_AS_FILETIME + (timegm(dt.timetuple()) * HUNDREDS_OF_NANOSECONDS)

def main():
  t = truxton.create()
  file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")

  url = file.newurl()

  url.account = "JimBillyRayJoeBob"
  url.format = truxton.URL_FORMAT_ASCII
  url.method = truxton.URL_METHOD_TYPE_USER_TYPED_IT_IN
  url.type = truxton.URL_TYPE_FIREFOX
  url.offset = 16384
  url.when =  date_to_filetime(datetime.utcnow())
  url.url = "https://www.truxwiki.com"

  if url.save() is True:
    print( "New URL saved as " + url.id )

if __name__ == "__main__":
  main()