Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Please review this: code to extract the season/episode or date from a TV show's title on a torrent site

by Cody Fendant (Hermit)
on Aug 18, 2016 at 07:17 UTC ( [id://1169974]=perlquestion: print w/replies, xml ) Need Help??

Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question:

Croods Qartulad -

ფილმის გარდატეხის მომენტი დგება მაშინ, როცა გრუგი ხვდება, რომ შიშზე დაფუძნებული მისი მეთოდი აღარ მუშაობს. სამყარო ფაქტიურად ნაწილ-ნაწილ იშლება (ფილმის მოქმედება კონტინენტთა ცვლის პერიოდში ხდება) და გამოქვაბულში დამალვის ძველი ჩვევები გადაშენებამდე მიგვიყვანს. ერთ ლამაზ ანიმაციურ სცენაში, გრუგი საბოლოოდ სწავლობს, რომ მიიღოს ახალი. ის იყენებს გაის იდეებს – „ბახს“ ესვრის ორმოდან გამოსასვლელად, იყენებს ფრთას და რაც მთავარია, იყენებს თავის წარმოსახვას, რათა გამოქვაბულის კედელზე ამბავი დახატოს. ეს მომენტი ძალიან ძლიერია: მამა, რომელიც ერთ დროს ჯიუტი ტრადიციების სიმბოლო იყო, ახლა ცვლილებების მოწაფე ხდება.

საბოლოოდ, „კრუდსები“ გადმოსცემს უნივერსალურ გზავნილს: . კრუდსები არ პოულობენ ახალ გამოქვაბულს – ისინი პოულობენ ახალ სამყაროს. ფილმი ასკვნის, რომ უსაფრთხოება არ არის სტატიკური გამოქვაბული, არამედ უნარი, შეეგუო ცვლილებებს და ენდო ერთმანეთს. გრუგი ხვდება, რომ მისი საქმე არ არის კარის ჩაკეტვა, არამედ იმის სწავლება, თუ როგორ ააშენონ ახალი კარი სადაც არ უნდა წავიდნენ. ქართულად „ოჯახი“ ნიშნავს სიახლოვესა და მხარდაჭერას. „კრუდსები“ სწორედ ამ იდეას ადიდებს და გვიჩვენებს, რომ გამოქვაბულის მკვიდრ ოჯახსაც კი შეუძლია ევოლუცია, თუ ისინი მზის ამოსვლას ერთად შეხვდებიან.

The turning point of the film comes when Grug realizes that his fear-based leadership is no longer working. The world is literally breaking apart (the film is set during a continental shift), and the old ways of hiding in a cave will lead to extinction. In a beautifully animated sequence, Grug finally learns to embrace the new. He uses Guy’s ideas—throwing a “bang” to escape a pit, using a wing, and most importantly, using his imagination to draw a story on the cave wall. This moment is powerful: the father, once the symbol of stubborn tradition, becomes a student of change. croods qartulad

This status quo is shattered by two events: the destruction of their cave and the arrival of Guy, a more inventive and forward-thinking young man. Guy represents change, creativity, and the “spark of ideas.” Unlike Grug, who uses brute force and fear, Guy uses his brain. He introduces the family to fire, shoes, and the concept of “following the sun to tomorrow.” The film cleverly uses the character of Eep, Grug’s rebellious daughter, as the bridge between these two worlds. She is drawn to Guy’s optimism and freedom, challenging her father’s outdated rules.

Ultimately, The Croods delivers a universal message: . The Croods do not find a new cave; they find a new world. The film concludes that safety is not a static cave but the ability to adapt and trust one another. Grug learns that his job is not to block the door, but to teach his family how to build a new door wherever they go. In Georgian, ოჯახი (ojakhi) means family—a word that implies closeness and support. კრუდსები celebrates that idea, showing that even a family of cavemen can evolve, as long as they face the sunrise together. ქართული ვერსია (Georgian Translation) ოჯახის ევოლუცია: ესე ფილმზე „კრუდსები“ 2013 წელს DreamWorks Animation-ის მიერ შექმნილი ფილმი „კრუდსები“ ბევრად მეტია, ვიდრე უბრალოდ ფერადი და მხიარული ანიმაციური კომედია. ეს არის ღრმა ისტორია გადარჩენაზე, ცვლილებებსა და ოჯახის განუწყვეტელ კავშირებზე. სათაური, რომელიც ქართულად „კრუდსები“ გახდა, ხაზს უსვამს ისტორიის კოლექტიურ ბუნებას – ეს არ არის მხოლოდ ერთი კაცის, გრუგის ისტორია, არამედ მთელი კრუდსების ოჯახის. ამ პრეისტორიული ოჯახის მოგზაურობის მეშვეობით, ფილმი გვასწავლის, რომ შიშმა შეიძლება გვაცოცხლოს, მაგრამ მხოლოდ გამბედაობასა და სიყვარულს შეუძლია, ნამდვილად ვიცხოვროთ. ის ოჯახს აცნობს ცეცხლს

ფილმის მთავარი კონფლიქტი ორ საპირისპირო ძალას შორისაა: და მომავლის ცნობისმოყვარეობა . გრუგი, ზედმეტად მფარველი მამა, ერთი ურყევი წესით ცხოვრობს: „ყველაფერი ახალი ცუდია“. ის ოჯახს გამოქვაბულში გამოკეტილი ატარებს, ყოველ ღამე ერთსა და იმავე ამბებს უყვება და არავის აძლევს ნაცნობი საზღვრების გადალახვის საშუალებას. ეს აზროვნება გამოხატავს ადამიანის ბუნებრივ ინსტინქტს – დარჩეს უსაფრთხო საზღვრებში. თუმცა, ფილმი ამტკიცებს, რომ ამ უსაფრთხოებას თავისი ფასი აქვს: ცხოვრება აღმოჩენების გარეშე ნახევრად ნაცხოვრებია.

The central conflict of the film is between two opposing forces: versus curiosity for the future . Grug, the overprotective father, lives by one rigid rule: “Anything new is bad.” He keeps his family locked in a cave, telling the same stories every night, ensuring that no one ever explores beyond the familiar. This mindset represents a natural human instinct—to stay within safe boundaries. However, the film argues that this safety comes at a cost: a life without discovery is a life half-lived. the overprotective father

ამ მდგომარეობას ორი მოვლენა არღვევს: მათი გამოქვაბულის განადგურება და გაის გამოჩენა – უფრო გამომგონებელი და წინდახედული ახალგაზრდა. გაი განასახიერებს ცვლილებას, შემოქმედებითობასა და „იდეების ნაპერწკალს“. გრუგისგან განსხვავებით, რომელიც ძალასა და შიშს იყენებს, გაი თავის გონებას იყენებს. ის ოჯახს აცნობს ცეცხლს, ფეხსაცმელს და „მზის გაყოლების“ კონცეფციას. ფილმი ჭკვიანურად იყენებს გრუგის მეამბოხე ქალიშვილის, იპის პერსონაჟს, როგორც ხიდს ამ ორ სამყაროს შორის. იპი მიიზიდავს გაის ოპტიმიზმი და თავისუფლება, რაც მამამისის მოძველებულ წესებს ეწინააღმდეგება.

Replies are listed 'Best First'.
Re: Please review this: code to extract the season/episode or date from a TV show's title on a torrent site
by Anonymous Monk on Aug 18, 2016 at 07:39 UTC

    About 0-stripping, if you are going to use the value as a number, I would got with + 0; else s/^0+//. (Perl, as you know, would convert the string to number if needed.)

Re: Please review this: code to extract the season/episode or date from a TV show's title on a torrent site
by Anonymous Monk on Aug 18, 2016 at 08:09 UTC

    If you are going to return a hash reference from extract_episode_data() ...

    sub extract_show_info { my $input_string = shift(); my $result = undef; if ( $result = extract_episode_data($input_string) ) { $result->{type} = 'se'; } elsif ( my @date = $_ =~ /$RE{time}{ymd}{-keep}/ ) { $result = { ... }; } return $result; } sub extract_episode_data { my $input_string = shift(); if ( ... ) { my $episode_data = { season => $1, episode => $2 }; return $episode_data; } else { return; } }

    ... why not set the type in there too? That would lead to something like ...

    sub extract_show_info { my $input_string = shift @_; my $result = extract_episode_data($input_string); $result and return $result; if ( my @date = $_ =~ /$RE{time}{ymd}{-keep}/ ) { return { ... }; } return; } sub extract_episode_data { my $input_string = shift @_; if ( ... ) { return { type => 'se', season => $1, episode => $2 }; } return; }
      ... why not set the type in there too?

      Makes sense, but I was trying to keep the two completely separate, de-coupled or whatever the right word is. Then I can re-use the season-episode sub cleanly for something else? Maybe I'm over-thinking.

Re: Please review this: code to extract the season/episode or date from a TV show's title on a torrent site
by Anonymous Monk on Aug 18, 2016 at 08:39 UTC

    Note to self: Regexp::Common::time provides the time regex, not Regexp::Common.

    One would be lucky to always have the date as year-month-day as the only variation instead of other two. So I take it then the files not matching your season-episode regex, would have the date only in that format?.

      That's a really tricky question.

      I don't see many other date formats, and there's really no way, in code at least, to deal with the possibility that someone has got the month and date the wrong way round and their August 1 is really January 8.

        You could look at consecutively-numbered episodes and see if they are 1 week (or whatever) apart. Or at least that each later-numbered episode has a later date.

        Yup ... may need to account for idiosyncrasies per provider, say by assigning a different regex/parser.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1169974]
Approved by Erez
Front-paged by Corion
help
Chatterbox?
and all is quiet...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2025-12-14 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (94 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.