Changeset 57 for trunk/Modules/Meet


Ignore:
Timestamp:
May 27, 2020, 8:04:56 PM (5 years ago)
Author:
chronos
Message:
  • Added: Allow to disable MeetSource in database.
  • Added: Show how many meet items were parsed and how many new added.
Location:
trunk/Modules/Meet
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Meet/Import/Amblar.php

    r41 r57  
    2929  {
    3030    $Output = parent::Import();
     31    $this->AddTimeInterval = 24 * 60 * 60;
    3132    $Content = file_get_contents($this->URL);
    3233
     
    5657      if ($Type == 'odpovězeno') continue;
    5758      $MeetItem->Time = trim(GetTextBetween($Item, '<span class="dwqa-date">', '</span>'));
    58       if (mb_substr($MeetItem->Time, 0, 4) == 'před') 
    59       {           
     59      if (mb_substr($MeetItem->Time, 0, 4) == 'před')
     60      {
    6061        $Parts = explode(' ', $MeetItem->Time);
    6162        if ($Parts[2] == 'hours') $MeetItem->Time = strtotime("-".$Parts[1]." hours");
     
    7374      $MeetItem->Source = $this->Id;
    7475      $Output .= $this->ImportItem($MeetItem);
    75       $this->AddedCount += $MeetItem->AddIfNotExist(24 * 60 * 60);
     76      $this->MeetItems[] = $MeetItem;
    7677    }
    7778    return $Output;
  • trunk/Modules/Meet/Import/AstraPraha.php

    r37 r57  
    3939      $MeetItem->Database = $this->Database;
    4040      $MeetItem->Source = $this->Id;
    41       $this->AddedCount += $MeetItem->AddIfNotExist();
     41      $this->MeetItems[] = $MeetItem;
    4242    }
    4343    return $Output;
  • trunk/Modules/Meet/Import/Csts.php

    r37 r57  
    4545      $MeetItem->Database = $this->Database;
    4646      $MeetItem->Source = $this->Id;
    47       $this->AddedCount += $MeetItem->AddIfNotExist();
     47      $this->MeetItems[] = $MeetItem;
    4848    }
    4949    return $Output;
  • trunk/Modules/Meet/Import/Ella.php

    r45 r57  
    66  {
    77    $Output = parent::Import();
     8    $this->AddCompareTime = false;
     9    $this->AddCompareRemoteId = true;
    810    $Content = file_get_contents($this->URL);
    911
     
    3840      $MeetItem->Database = $this->Database;
    3941      $MeetItem->Source = $this->Id;
    40       $this->AddedCount += $MeetItem->AddIfNotExist(0, false, true);
     42      $this->MeetItems[] = $MeetItem;
    4143    }
    4244    return $Output;
  • trunk/Modules/Meet/Import/Eso.php

    r37 r57  
    2929      if (strpos($MeetItem->Gender, 'partnerku') !== false) $MeetItem->Gender = Gender::Male;
    3030        else if (strpos($MeetItem->Gender, 'partnera') !== false) $MeetItem->Gender = Gender::Female;
    31         else $MeetItem->Gender = Gender::Undefined;     
     31        else $MeetItem->Gender = Gender::Undefined;
    3232      $Small = GetTextBetween($Item, '<small>', '</small>');
    33       if (strpos($Small, '/') != false){
    34         $MeetItem->Location = substr(trim(substr($Small, 0, strpos($Small, '/') - 1)), 1, -1);
    35         $Small = substr($Small, strpos($Small, '/') + 1);
    36       }     
     33      if (strpos($Small, '/') != false)
     34      {
     35        $MeetItem->Location = substr(trim(substr($Small, 0, strpos($Small, '/') - 1)), 1, -1);
     36        $Small = substr($Small, strpos($Small, '/') + 1);
     37      }
    3738      $MeetItem->Time = trim($Small);
    3839      $MeetItem->Time = HumanDateToTime($MeetItem->Time);
    3940      $MeetItem->Message = trim(GetTextBetween($Item, '<p class="lead">', '</p>'));
    40       $MeetItem->Age = GetAgeFromText($MeetItem->Message);     
     41      $MeetItem->Age = GetAgeFromText($MeetItem->Message);
    4142      $MeetItem->Height = GetHeightFromText($MeetItem->Message);
    4243      $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
     
    4950      $MeetItem->Database = $this->Database;
    5051      $MeetItem->Source = $this->Id;
    51       $this->AddedCount += $MeetItem->AddIfNotExist();
     52      $this->MeetItems[] = $MeetItem;
    5253    }
    5354    return $Output;
  • trunk/Modules/Meet/Import/Facebook.php

    r37 r57  
    55  function Import()
    66  {
    7     return;   
     7    return;
    88    $Output = parent::Import();
    99    $Content = file_get_contents($this->URL);
     
    3636      $MeetItem->Height = trim(GetTextBetween($Item, "výška:", 'cm'));
    3737      $MeetItem->Message = trim(html_entity_decode(strip_tags(GetTextBetween($Item, 'data-ft="&#123;&quot;tn&quot;:&quot;K&quot;&#125;">', '</div>'))));
    38       $MeetItem->Age = GetAgeFromText($MeetItem->Message);     
     38      $MeetItem->Age = GetAgeFromText($MeetItem->Message);
    3939      $MeetItem->Height = GetHeightFromText($MeetItem->Message);
    4040      $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
     
    4848      $MeetItem->Database = $this->Database;
    4949      $MeetItem->Source = $this->Id;
    50       $this->AddedCount += $MeetItem->AddIfNotExist();
     50      $this->MeetItems[] = $MeetItem;
    5151    }
    5252    return $Output;
  • trunk/Modules/Meet/Import/MajkluvSvet.php

    r37 r57  
    4848      $MeetItem->Database = $this->Database;
    4949      $MeetItem->Source = $this->Id;
    50       $this->AddedCount += $MeetItem->AddIfNotExist();
     50      $this->MeetItems[] = $MeetItem;
    5151    }
    52     return $Output; 
     52    return $Output;
    5353  }
    5454}
  • trunk/Modules/Meet/Import/SalsaDance.php

    r37 r57  
    4040      $MeetItem->Database = $this->Database;
    4141      $MeetItem->Source = $this->Id;
    42       $this->AddedCount += $MeetItem->AddIfNotExist();
     42      $this->MeetItems[] = $MeetItem;
    4343    }
    44     return $Output; 
     44    return $Output;
    4545  }
    4646}
  • trunk/Modules/Meet/Import/Seznamka.php

    r54 r57  
    99    $Content = str_replace("(adsbygoogle = window.adsbygoogle || []).push({});", "", $Content);
    1010    $BlockStart = '<h1>Tanec ... : Seznamka</h1>';
    11     $BlockEnd = '<h2>Doporučujeme</h2>';
     11    $BlockEnd = 'rel=\'prev\'>Předchozí</a>';
    1212    $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
    1313    if ($Content == '')
     
    5050      $MeetItem->Database = $this->Database;
    5151      $MeetItem->Source = $this->Id;
    52       $this->AddedCount += $MeetItem->AddIfNotExist();
     52      $this->MeetItems[] = $MeetItem;
    5353    }
    5454    return $Output;
  • trunk/Modules/Meet/Import/TanecniSkola.php

    r37 r57  
    55  function Import()
    66  {
    7     $Output = '';
     7    $Output = parent::Import();
    88    $HeightRange = array(
    99      '< 120 cm' => 120,
     
    2626      '200 cm <' => 205,
    2727    );
    28 
    29     $Output = parent::Import();
    3028    $Content = file_get_contents($this->URL);
    3129
     
    9290        $MeetItem->Database = $this->Database;
    9391        $MeetItem->Source = $this->Id;
    94         $this->AddedCount += $MeetItem->AddIfNotExist();
     92        $this->MeetItems[] = $MeetItem;
    9593      }
    9694    }
  • trunk/Modules/Meet/Import/Vavruska.php

    r43 r57  
    4141      $MeetItem->Source = $this->Id;
    4242      if ($MeetItem->Name == 'Nový Design Inzerátů') continue;
    43       $this->AddedCount += $MeetItem->AddIfNotExist();
     43      $this->MeetItems[] = $MeetItem;
    4444    }
    4545    return $Output;
  • trunk/Modules/Meet/Meet.php

    r55 r57  
    326326  {
    327327    $Output = '';
    328     if (($Id != null) and is_numeric($Id)) $Where = 'Id='.$Id;
    329       else $Where = '1';
     328    $Where = '(Enabled=1)';
     329    if (($Id != null) and is_numeric($Id)) $Where .= ' AND (Id='.$Id.')';
    330330    $DbResult = $this->Database->select('MeetSource', '*', $Where);
    331331    while ($DbRow = $DbResult->fetch_assoc())
     
    353353      $Source->Name = $DbRow['Name'];
    354354      $this->Items[] = $Source;
    355       $Output .= $Source->Import();
     355      $Output .= $Source->DoImport();
    356356    }
    357357    return $Output;
     
    366366  public $Id;
    367367  public $Database;
     368  public $MeetItems;
     369  public $AddCompareTime;
     370  public $AddCompareRemoteId;
     371  public $AddTimeInterval;
     372  public $AddedCount;
     373
     374  function __construct()
     375  {
     376    $this->MeetItems = array();
     377    $this->AddedCount = 0;
     378    $this->AddCompareTime = true;
     379    $this->AddCompareRemoteId = false;
     380    $this->AddTimeInterval = 0;
     381  }
    368382
    369383  function Import()
    370384  {
     385    return '';
     386  }
     387
     388  function DoImport()
     389  {
     390    $this->MeetItems = array();
    371391    $this->AddedCount = 0;
    372     $Output = 'Parsing '.$this->Name.' ('.$this->Id.')...</br>';
     392    $Output = 'Parsing '.$this->Name.' (#'.$this->Id.')...';
     393    $Output .= $this->Import();
     394    $Output .= ' parsed: '.count($this->MeetItems);
     395    foreach ($this->MeetItems as $MeetItem)
     396    {
     397      $this->AddedCount += $MeetItem->AddIfNotExist($this->AddTimeInterval, $this->AddCompareTime, $this->AddCompareRemoteId);
     398    }
     399    $Output .= ', new added: '.$this->AddedCount;
     400    $Output .= '</br>'."\n";
    373401    return $Output;
    374402  }
Note: See TracChangeset for help on using the changeset viewer.