Class JellyfinExportMetadata

java.lang.Object
com.lariflix.jemm.csv.JellyfinExportMetadata

public class JellyfinExportMetadata extends Object
The JellyfinExportMetadata class is responsible for exporting metadata from a Jellyfin instance to a CSV file. It loads the metadata, processes it, and writes it to the specified destination path.
Since:
1.2.0
Version:
1.0
Author:
CesarBianchi
See Also:
  • Constructor Details

    • JellyfinExportMetadata

      public JellyfinExportMetadata()
      Default constructor for the JellyfinExportMetadata class.
      Since:
      1.2.0
    • JellyfinExportMetadata

      public JellyfinExportMetadata(String cPath, JellyfinInstanceDetails instData)
      Constructor for the JellyfinExportMetadata class with parameters.
      Parameters:
      cPath - The destination path for the CSV file.
      instData - The instance data for the Jellyfin instance.
      Since:
      1.2.0
  • Method Details

    • getDestinationPath

      public String getDestinationPath()
      Gets the destination path for the CSV file.
      Returns:
      The destination path.
      Since:
      1.2.0
    • setDestinationPath

      public void setDestinationPath(String cDestinationPath)
      Sets the destination path for the CSV file.
      Parameters:
      cDestinationPath - The destination path to set.
      Since:
      1.2.0
    • getInstanceData

      public JellyfinInstanceDetails getInstanceData()
      Gets the instance data for the Jellyfin instance.
      Returns:
      The instance data.
      Since:
      1.2.0
    • setInstanceData

      public void setInstanceData(JellyfinInstanceDetails instanceData)
      Sets the instance data for the Jellyfin instance.
      Parameters:
      instanceData - The instance data to set.
      Since:
      1.2.0
    • startProcess

      public JellyfinResponseStandard startProcess()
      Starts the process of exporting metadata from the Jellyfin instance to a CSV file. This method performs the following steps: 1. Checks if the destination path is not empty. 2. Loads the items from the Jellyfin instance. 3. Loads the sub-items for each item. 4. Transforms the items and sub-items into lines for the CSV file. 5. Creates the CSV file with the collected lines. If any step fails, it sets the appropriate response code and message in the process result.
      Returns:
      A JellyfinResponseStandard object containing the result of the process. If the process is successful, the response code is "CSV_EXP_001" and the response message indicates the file was generated successfully. If the process fails, the response code and message indicate the error.
      Since:
      1.2.0
    • loadItems

      public boolean loadItems() throws IOException, MalformedURLException, org.json.simple.parser.ParseException
      Loads the items from the Jellyfin instance. This method performs the following steps: 1. Initializes a LoadFolders object to load folders and subfolders from the Jellyfin instance. 2. Sets the Jellyfin instance URL, API token, and admin user ID for the LoadFolders object. 3. Requests the folders from the Jellyfin instance. 4. For each folder, initializes a JellyfinReportInventoryItem object and sets its item. 5. Initializes a LoadItemMetadata object to load metadata for each item. 6. Sets the Jellyfin instance URL, API token, admin user ID, and item ID for the LoadItemMetadata object. 7. Requests the item metadata from the Jellyfin instance and sets it for the JellyfinReportInventoryItem object. 8. Adds the JellyfinReportInventoryItem object to the items list. 9. Sorts the items list by name in ascending order.
      Returns:
      true if the items were loaded successfully, false otherwise.
      Throws:
      IOException - If an I/O error occurs.
      MalformedURLException - If the URL is malformed.
      org.json.simple.parser.ParseException - If a parsing error occurs.
      Since:
      1.2.0
    • loadSubItems

      public boolean loadSubItems()
      Loads the sub-items for each item from the Jellyfin instance. This method performs the following steps: 1. Initializes a LoadItems object to load sub-items from the Jellyfin instance. 2. Sets the Jellyfin instance URL, API token, and admin user ID for the LoadItems object. 3. For each item, sets the parent ID for the LoadItems object and requests the sub-items from the Jellyfin instance. 4. Sets the sub-items for each item. 5. For each sub-item, initializes a LoadItemMetadata object to load metadata for the sub-item. 6. Sets the Jellyfin instance URL, API token, admin user ID, and sub-item ID for the LoadItemMetadata object. 7. Requests the sub-item metadata from the Jellyfin instance and sets it for the sub-item.
      Returns:
      true if the sub-items were loaded successfully, false otherwise.
      Since:
      1.2.0
    • getStandardHeader

      public Field[] getStandardHeader()
      Retrieves the standard header fields from the JellyfinCsvStructure class.
      Returns:
      An array of Field objects representing the standard header fields.
      Since:
      1.2.0
    • loadLines

      public boolean loadLines()
      Loads the lines for the CSV file from the items and sub-items. This method performs the following steps: 1. Initializes a JellyfinCsvStructure object and a TransformDateFormat object. 2. Iterates over the items list and processes each item. 3. For each item, sets the fields of the JellyfinCsvStructure object with the item's metadata. 4. Adds the JellyfinCsvStructure object to the lines list. 5. Iterates over the sub-items of each item and processes each sub-item. 6. For each sub-item, sets the fields of the JellyfinCsvStructure object with the sub-item's metadata. 7. Adds the JellyfinCsvStructure object to the lines list.
      Returns:
      true if the lines were loaded successfully, false otherwise.
      Since:
      1.2.0
    • createCSVFile

      public boolean createCSVFile()
      Creates the CSV file with the collected metadata. This method performs the following steps: 1. Prints the header as the first line of the file. 2. Prints all collected lines. 3. Closes the file and opens it with the default application.
      Returns:
      true if the CSV file was created successfully, false otherwise.
      Since:
      1.2.0
    • getProcessFinalResult

      public JellyfinResponseStandard getProcessFinalResult()
    • setProcessFinalResult

      public void setProcessFinalResult(JellyfinResponseStandard processFinalResult)