Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Einthusan Movie Release Year return #30230

Open
vmax77 opened this issue Nov 12, 2021 · 1 comment
Open

Einthusan Movie Release Year return #30230

vmax77 opened this issue Nov 12, 2021 · 1 comment

Comments

@vmax77
Copy link

vmax77 commented Nov 12, 2021

Checklist

  • [ x ] I'm reporting a site feature request
  • [ x ] I've verified that I'm running youtube-dl version 2021.06.06
  • [ x ] I've searched the bugtracker for similar site feature requests including closed ones

Description

Hi

I use Einthusan.ca to download regional movies, and it would be really useful to automate the downloading and naming for plex if YouTube-dl could also return release year as a return variable. Currently when i query for release_year it outputs NA.

@dirkf
Copy link
Contributor

dirkf commented Nov 12, 2021

The release_year field is only for use with a media item that belong to a music album (it says).

The page has some free text that is a year and a <time> element that is tagged released date on einthusan.

This patch gets the latter since a bug in the get_elements_by_class() function prevents getting the first one reliably. The timestamp is set, and hence the upload_date.

--- old/youtube_dl/extractor/einthusan.py
+++ new/youtube_dl/extractor/einthusan.py
@@ -11,9 +11,12 @@
     compat_urlparse,
 )
 from ..utils import (
+    clean_html,
     extract_attributes,
     ExtractorError,
-    get_elements_by_class,
+    get_element_by_class,
+    ISO639Utils,
+    parse_iso8601,
     urlencode_postdata,
 )
 
@@ -95,17 +98,55 @@
 
         self._sort_formats(formats)
 
-        description = get_elements_by_class('synopsis', webpage)[0]
+        result = {
+            'id': video_id,
+            'title': title,
+            'formats': formats,
+        }
+        description = get_element_by_class('synopsis', webpage)
+        if description:
+            result['description'] = description
+
         thumbnail = self._html_search_regex(
             r'''<img[^>]+src=(["'])(?P<url>(?!\1).+?/moviecovers/(?!\1).+?)\1''',
             webpage, 'thumbnail url', fatal=False, group='url')
         if thumbnail is not None:
             thumbnail = compat_urlparse.urljoin(url, thumbnail)
+            result['thumbnail'] = thumbnail
+        upload_date = self._search_regex(
+            r'''(<time\s[^>]*?\bdatetime\s*=[^>]+>)''',
+            webpage, 'upload date', default=None)
+        if upload_date:
+            upload_date = extract_attributes(upload_date) or {}
+            timestamp = parse_iso8601(upload_date.get('datetime'))
+            if timestamp:
+                result['timestamp'] = timestamp
+        info = clean_html(get_element_by_class('info', webpage) or '')
+        release_year = re.findall(r'\d{4}', info) or None
+        if release_year:
+            release_year = release_year[0]
+            info = re.sub(release_year, '', info)
+            if 'timestamp' not in result:
+                result['upload_date'] = release_year + '0601'
+        language = re.findall(r'\w+', info)
+        print(language)
+        if language:
 
-        return {
-            'id': video_id,
-            'title': title,
-            'formats': formats,
-            'thumbnail': thumbnail,
-            'description': description,
-        }
+            class Lang(ISO639Utils):
+                @classmethod
+                def natural2short(cls, name):
+                    """Hackily guess ISO 639-1 language code from natural language name"""
+                    test_name = name.lower()
+                    for short_name, long_name in cls._lang_map.items():
+                        if test_name.startswith(long_name):
+                            return short_name
+                    # omit this - utils bug
+                    # return test_name[:2]
+
+            language = Lang.natural2short(language[0])
+            if language:
+                for fmt in formats:
+                    if 'language' not in fmt:
+                        fmt['language'] = language
+
+        return result

dirkf added a commit to dirkf/youtube-dl that referenced this issue Nov 13, 2021
Eg, in [1], the class with name 'plist-info' was found when searching for 'info'.

1. ytdl-org#30230
dirkf added a commit to dirkf/youtube-dl that referenced this issue Mar 11, 2024
Eg, in [1], the class with name 'plist-info' was found when searching for 'info'.

1. ytdl-org#30230
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants