<commit_before>// Import the neccesary modules.
import asyncq from 'async-q';

import Movie from '../../models/Movie';
import { fanart, omdb, tmdb, trakt } from '../../config/constants';
import {
  checkImages,
  onError
} from '../../utils';

/** Class for saving movies. */
export default class MovieHelper {

  /**
   * Create an helper object for movie content.
   * @param {String} name - The name of the content provider.
   */
  constructor(name) {
    /**
     * The name of the torrent provider.
     * @type {String}
     */
    this.name = name;
  }

  /**
   * Update the torrents for an existing movie.
   * @param {Movie} movie - The new movie.
   * @param {Movie} found - The existing movie.
   * @param {String} language - The language of the torrent.
   * @param {String} quality - The quality of the torrent.
   * @return {Movie} - A movie with merged torrents.
   */
  _updateTorrent(movie, found, language, quality) {
    let update = false;

    if (found.torrents[language] && movie.torrents[language]) {
      if (found.torrents[language][quality] && movie.torrents[language][quality]) {
        if (found.torrents[language][quality].seeds > movie.torrents[language][quality].seeds) {
          update = true;
        } else if (movie.torrents[language][quality].seeds > found.torrents[language][quality].seeds) {
          update = false;
        } else if (found.torrents[language][quality].url === movie.torrents[language][quality].url) {
          update = true;
        }
      } else if (found.torrents[language][quality] && !movie.torrents[language][quality]) {
        update = true;
      }
    } else if (found.torrents[language] && !movie.torrents[language]) {
      if (found.torrents[language][quality]) {
        movie.torrents[language] = {};
        update = true;
      }
    }

    if (update) movie.torrents[language][quality] = found.torrents[language][quality];
    return movie;
  }

  /**
   * @description Update a given movie.
   * @function Helper#updateMovie
   * @memberof module:providers/movie/helper
   * @param {Movie} movie - The movie to update its torrent.
   * @returns {Movie} - A newly updated movie.
   */
  async _updateMovie(movie) {
    try {
      const found = await Movie.findOne({
        _id: movie._id
      }).exec();
      if (found) {
        logger.info(`${this.name}: '${found.title}' is an existing movie.`);

        if (found.torrents) {<commit_msg>minor docs fix<commit_after>// Import the neccesary modules.
import asyncq from 'async-q';

import Movie from '../../models/Movie';
import { fanart, omdb, tmdb, trakt } from '../../config/constants';
import {
  checkImages,
  onError
} from '../../utils';

/** Class for saving movies. */
export default class MovieHelper {

  /**
   * Create an helper object for movie content.
   * @param {String} name - The name of the content provider.
   */
  constructor(name) {
    /**
     * The name of the torrent provider.
     * @type {String}
     */
    this.name = name;
  }

  /**
   * Update the torrents for an existing movie.
   * @param {Movie} movie - The new movie.
   * @param {Movie} found - The existing movie.
   * @param {String} language - The language of the torrent.
   * @param {String} quality - The quality of the torrent.
   * @return {Movie} - A movie with merged torrents.
   */
  _updateTorrent(movie, found, language, quality) {
    let update = false;

    if (found.torrents[language] && movie.torrents[language]) {
      if (found.torrents[language][quality] && movie.torrents[language][quality]) {
        if (found.torrents[language][quality].seeds > movie.torrents[language][quality].seeds) {
          update = true;
        } else if (movie.torrents[language][quality].seeds > found.torrents[language][quality].seeds) {
          update = false;
        } else if (found.torrents[language][quality].url === movie.torrents[language][quality].url) {
          update = true;
        }
      } else if (found.torrents[language][quality] && !movie.torrents[language][quality]) {
        update = true;
      }
    } else if (found.torrents[language] && !movie.torrents[language]) {
      if (found.torrents[language][quality]) {
        movie.torrents[language] = {};
        update = true;
      }
    }

    if (update) movie.torrents[language][quality] = found.torrents[language][quality];
    return movie;
  }

  /**
   * Update a given movie.
   * @param {Movie} movie - The movie to update its torrent.
   * @returns {Movie} - A newly updated movie.
   */
  async _updateMovie(movie) {
    try {
      const found = await Movie.findOne({
        _id: movie._id
      }).exec();
      if (found) {
        logger.info(`${this.name}: '${found.title}' is an existing movie.`);

        if (found.torrents) {
{'fraction_non_alphanumeric': 0.1458551941238195, 'fraction_numerical': 0.0, 'mean_word_length': 2.6945736434108527, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7541102', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1460, 'n_words': 391}