Füge Ananta Game News Bridge hinzu
This commit is contained in:
		
							
								
								
									
										90
									
								
								AnantaBridge.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								AnantaBridge.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,90 @@
 | 
			
		||||
<?php
 | 
			
		||||
class AnantaBridge extends BridgeAbstract {
 | 
			
		||||
 | 
			
		||||
    const MAINTAINER = 'Akamaru';
 | 
			
		||||
    const NAME = 'Ananta Game News';
 | 
			
		||||
    const URI = 'https://www.anantagame.com/news/';
 | 
			
		||||
    const CACHE_TIMEOUT = 21600; // 21600 = 6h
 | 
			
		||||
    const DESCRIPTION = 'Get the latest news from Ananta Game';
 | 
			
		||||
    
 | 
			
		||||
    public function getIcon(){
 | 
			
		||||
        return 'https://www.anantagame.com/images/20241204/1733327984739_d3f0254e11.jpg';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function collectData() {
 | 
			
		||||
        // Retrieve webpage
 | 
			
		||||
        $pageUrl = self::URI;
 | 
			
		||||
        $html = getSimpleHTMLDOM($pageUrl)
 | 
			
		||||
            or returnServerError('Could not request webpage: ' . $pageUrl);
 | 
			
		||||
 | 
			
		||||
        // Process articles
 | 
			
		||||
        foreach($html->find('.news-item') as $element) {
 | 
			
		||||
 | 
			
		||||
            if(count($this->items) >= 10) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $item = array();
 | 
			
		||||
            
 | 
			
		||||
            // Get article URI (link)
 | 
			
		||||
            $item['uri'] = $element->href;
 | 
			
		||||
            
 | 
			
		||||
            // Get article title
 | 
			
		||||
            $title_element = $element->find('.news-title', 0);
 | 
			
		||||
            if ($title_element) {
 | 
			
		||||
                $item['title'] = trim(strip_tags($title_element->innertext));
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            // Get article description/content
 | 
			
		||||
            $desc_element = $element->find('.news-desc', 0);
 | 
			
		||||
            if ($desc_element) {
 | 
			
		||||
                $article_content = trim(strip_tags($desc_element->innertext));
 | 
			
		||||
            } else {
 | 
			
		||||
                $article_content = '';
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            // Get article date
 | 
			
		||||
            $date_element = $element->find('.news-date', 0);
 | 
			
		||||
            if ($date_element) {
 | 
			
		||||
                $article_date = trim(strip_tags($date_element->innertext));
 | 
			
		||||
                $item['timestamp'] = strtotime($article_date);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            // Get article category
 | 
			
		||||
            $tag_element = $element->find('.js-news-tag', 0);
 | 
			
		||||
            if ($tag_element) {
 | 
			
		||||
                $article_category = trim(strip_tags($tag_element->innertext));
 | 
			
		||||
                $item['categories'] = array($article_category);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            // Get article image
 | 
			
		||||
            $img_element = $element->find('.news-item-right img', 0);
 | 
			
		||||
            if ($img_element) {
 | 
			
		||||
                $article_thumbnail = $img_element->src;
 | 
			
		||||
                $item['enclosures'] = array($article_thumbnail);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            // Build content with image and text
 | 
			
		||||
            $content = '';
 | 
			
		||||
            if (isset($article_thumbnail)) {
 | 
			
		||||
                $content .= '<img src="' . $article_thumbnail . '" alt="' . htmlspecialchars($item['title']) . '">';
 | 
			
		||||
            }
 | 
			
		||||
            if ($article_content) {
 | 
			
		||||
                $content .= '<p>' . $article_content . '</p>';
 | 
			
		||||
            }
 | 
			
		||||
            if (isset($article_category)) {
 | 
			
		||||
                $content .= '<p><b>Category:</b> ' . $article_category . '</p>';
 | 
			
		||||
            }
 | 
			
		||||
            if (isset($article_date)) {
 | 
			
		||||
                $content .= '<p><b>Date:</b> ' . $article_date . '</p>';
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            $item['content'] = $content;
 | 
			
		||||
            
 | 
			
		||||
            // Generate unique ID
 | 
			
		||||
            $item['uid'] = $item['uri'];
 | 
			
		||||
            
 | 
			
		||||
            $this->items[] = $item;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
} 
 | 
			
		||||
@@ -30,6 +30,10 @@ Diese Sammlung enthält verschiedene Bridge-Implementierungen für RSS-Bridge, u
 | 
			
		||||
  - **Vollständige Detailseiten**: Wenn aktiviert, werden zusätzliche Informationen von den Detailseiten abgerufen (langsamer)
 | 
			
		||||
- **Besonderheiten**: Verwendet den FreshRSS User-Agent zum Umgehen von CloudFlare-Schutz
 | 
			
		||||
 | 
			
		||||
### Ananta Game News Bridge
 | 
			
		||||
- **Beschreibung**: Generiert einen RSS-Feed für Ananta Game Neuigkeiten
 | 
			
		||||
- **Besonderheiten**: Extrahiert Titel, Inhalte, Bilder, Kategorien und Datum der News-Einträge
 | 
			
		||||
 | 
			
		||||
## Installation
 | 
			
		||||
 | 
			
		||||
1. Kopiere die gewünschten Bridge-Dateien in das `bridges`-Verzeichnis deiner RSS-Bridge-Installation
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user