Beispiel #1
0
def searchMetadataDate(p_filename, p_startDate, p_endDate):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_startDate: start of the date range we are searching for
	:type p_startDate: datetime
    :param p_endDate: end of the date range we are searching for
    :type p_endDate: datetime

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif

    :return: True if the datetime is inbetween p_startDate and p_endDate
    :rtype: bool
    """
    filecheck(p_filename)
    if getExtension(p_filename) == '.jpg' or getExtension(p_filename) == '.png' or getExtension(p_filename) == '.tiff':
        f_metadata = pyexiv2.ImageMetadata(p_filename)
        f_metadata.read()
        # print(f_metadata.exif_keys)
        if not containsMetadataDate(p_filename):
            return False
        f_cleanMetadataDate = getMetadataDate(p_filename)
        if p_startDate <= f_cleanMetadataDate <= p_endDate:
            return True
    else:
        earlySupportCheck(p_filename)
        # TODO add gif support
        return False
    return False
Beispiel #2
0
def searchArtists(p_filename, p_artist):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_artist: artist we are searching for in the metadata
	:type p_artist: string


    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif

    :return: True if p_artist was in artist metadata
    :rtype: bool
    """
    filecheck(p_filename)
    f_artists = getArtists(p_filename)
    if f_artists == []:
        return False
    # Note: the conditions for finding an artist are very relaxed.
    # We're only searching for a substring.
    # so if an artist entry is "composer: Sarah Sharp"
    # searches for: "composer", "Sarah Sharp", "Sarah", "sharp", and "Sar"
    # will all return true.
    # Perhaps a strictSearchArtists() function is needed
    for i_artist in f_artists:
        #print("finding artist:", p_artist.lower(), i_artist.lower())
        if p_artist.lower() in i_artist.lower():
            return True
    return False
Beispiel #3
0
def removeTag(p_filename, p_tag):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_tag: tag you will be removing from the tag metadata
	:type p_tag: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif
    :raise MetadataMissingError: if the file has no tag metadata
    :raise NoSuchItemError: if the file does not have p_artist in their tag list
    """
    filecheck(p_filename)
    if not containsTags(p_filename):
        raise MetadataMissingError("there is no tag data to remove")
    f_cleanXList = getTags(p_filename)
    # print("addTag() f_cleanXList\t\t", f_cleanXList)
    if p_tag not in f_cleanXList:
        raise NoSuchItemError(
            'The file \'{}\' does not contain the tag \'{}\' \n This operation cannot be performed'.format(
                p_filename, p_tag))
    f_cleanXList.remove(p_tag)
    if f_cleanXList == []:
        wipeTags(p_filename)
        return
    # print("removeTag() f_cleanXList\t\t", f_cleanXList)
    setTags(p_filename, f_cleanXList)
    return
Beispiel #4
0
def searchTitle(p_filename, p_searchForThis):
    """
    takes: filename as string (including path)
    returns: truth value of p_searchForThis being in the title
    always returns false when no title exists

    # Note: Title does not need to be entire search term to return true
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_searchForThis: title that we're checking for
    :type p_searchForThis: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif

    :return: True if p_searchForThis was in title metadata
    :rtype: bool
    """
    filecheck(p_filename)
    f_title = getTitle(p_filename)
    if f_title == "":
        return False
    if p_searchForThis in f_title:
        return True
    return False
Beispiel #5
0
def removeArtist(p_filename, p_artist):
    """
    removes artist from artist metadata

    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_artist: artist we are removing from the artist metadata
	:type p_artist: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif
    :raise MetadataMissingError: if the file has no artist metadata
    :raise NoSuchItemError: if the file does not have p_artist in their artist list
    """
    filecheck(p_filename)
    if not containsArtists(p_filename):
        raise MetadataMissingError("there is no artist data to remove")
    f_cleanXList = getArtists(p_filename)
    # print("removeArtist() f_cleanXList\t\t", f_cleanXList)
    # Note that p_artist must be an exact match with an entry to have it removed
    if p_artist not in f_cleanXList:
        raise NoSuchItemError(
            'The file \'{}\' does not contain the artist \'{}\' \n This operation cannot be performed'.format(
                p_filename, p_artist))
    f_cleanXList.remove(p_artist)
    if f_cleanXList == []:
        wipeArtists(p_filename)
        return
    setArtists(p_filename, f_cleanXList)
    return
Beispiel #6
0
def addDescr(p_filename, p_addThisToDescr):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_addThisToDescr: string you will be appending to the description metadata
	:type p_addThisToDescr: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif
    """
    filecheck(p_filename)
    f_setDescrToThis = getDescr(p_filename) + p_addThisToDescr
    setDescr(p_filename, f_setDescrToThis)
    return
Beispiel #7
0
def addTag(p_filename, p_tag):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_tag: tag you will be adding to the tag metadata
	:type p_tag: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif
    :raise DuplicateDataError: if the file already has this tag in its tag metadata
    """
    filecheck(p_filename)
    f_cleanXList = getTags(p_filename)
    # print("addTag() f_cleanXList\t\t", f_cleanXList)
    if p_tag in f_cleanXList:
        raise DuplicateDataError("file already contains this tag")
    f_cleanXList.insert(0, p_tag)
    setTags(p_filename, f_cleanXList)
    return
Beispiel #8
0
def searchVersionNum(p_filename, p_searchForThis):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_searchForThis: VersionNum that we're checking for
    :type p_searchForThis: int

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif

    :return: True if p_searchForThis was in VersionNum metadata
    :rtype: bool
    """
    filecheck(p_filename)
    f_VersionNum = getVersionNum(p_filename)
    if f_VersionNum == -1:
        return False
    if p_searchForThis in f_VersionNum:
        return True
    return False
Beispiel #9
0
def searchSeriesInstallment(p_filename, p_searchForThis):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_searchForThis: series installment that we're checking for
    :type p_searchForThis: int

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif

    :return: True if p_searchForThis was in series installment metadata
    :rtype: bool
    """
    filecheck(p_filename)
    f_series_installment = getSeriesInstallment(p_filename)
    if f_series_installment == -1:
        return False
    if p_searchForThis in f_series_installment:
        return True
    return False
Beispiel #10
0
def searchSource(p_filename, p_searchForThis):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_searchForThis: source url that we're checking for
    :type p_searchForThis: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif

    :return: True if p_searchForThis was in source metadata
    :rtype: bool
    """
    filecheck(p_filename)
    f_source = getSource(p_filename)
    if f_source == "":
        return False
    if p_searchForThis in f_source:
        return True
    return False
Beispiel #11
0
def searchDescr(p_filename, p_searchForThis):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_searchForThis: description that we're checking for
    :type p_searchForThis: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif

    :return: True if p_searchForThis was in description metadata
    :rtype: bool
    """
    filecheck(p_filename)
    f_descr = getDescr(p_filename)
    if f_descr == "":
        return False
    if p_searchForThis in f_descr:
        return True
    return False
Beispiel #12
0
def addArtist(p_filename, p_artist):
    """
    appends new artist to the artist metadata

    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_artist: artist we are adding into the artist metadata
	:type p_artist: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif
    :raise DuplicateDataError: if the file already has this artist in its artist metadata
    """
    filecheck(p_filename)
    f_cleanXList = getArtists(p_filename)
    # print("addArtist() f_cleanXList\t\t", f_cleanXList)
    if p_artist in f_cleanXList:
        raise DuplicateDataError("file already contains this artist")
    f_cleanXList.insert(0, p_artist)
    setArtists(p_filename, f_cleanXList)
    return
Beispiel #13
0
def searchTags(p_filename, p_tag):
    """
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_tag: tag we will search the tag metadata for
	:type p_tag: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif

    :return: True if p_tag was in tag metadata
    :rtype: bool
    """
    filecheck(p_filename)
    f_keywords = getTags(p_filename)
    # Note: these are strict searches. They are case sensative
    # non case sensative searches may require longer execution time
    if f_keywords == []:
        return False
    if p_tag in f_keywords:
        return True
    return False
Beispiel #14
0
def searchTaggerMark(p_filename, p_searchForThis):
    """
    takes: filename as string (including path)
    returns: truth value of p_searchForThis being in the TaggerMark
    always returns false when no TaggerMark exists

    # Note: TaggerMark does not need to be entire search term to return true
    :param p_filename: name/path of the file
	:type p_filename: string
	:param p_searchForThis: TaggerMark that we're checking for
    :type p_searchForThis: string

    :raise UnknownFiletypeError: if the filetype cannot be found
    :raise UnsupportedFiletypeError: if the filetype is not .jpg, .png, or .gif

    :return: True if p_searchForThis was in TaggerMark metadata
    :rtype: bool
    """
    filecheck(p_filename)
    if containsTaggerMark(p_filename) == False:
        return False
    if p_searchForThis in containsTaggerMark(p_filename):
        return True
    return False