Giter VIP home page Giter VIP logo

Comments (14)

ukdtom avatar ukdtom commented on May 31, 2024

Might take some time here, and not easy ;-)

from srt2utf-8.bundle.

pristas-peter avatar pristas-peter commented on May 31, 2024

Hi, it's kinda possible with this code:

  • you can get a list of subtitle files and languages which are associated with given part directly from plex sqlite db
  • problem is that you will get a list of results only on second agent run on the same part (because the results are written to the db after all agents finish running)
  • maybe you could dispatch this select on another thread with some timeout...
  • feel free to use it if you find it useful
    plugins_dir = os.path.dirname(os.path.dirname(os.getcwd()))
    media_dir = os.path.join(os.path.dirname(plugins_dir), 'Media', 'localhost')

    db_file = os.path.join(plugins_dir, 'Databases', 'com.plexapp.plugins.library.db')
    conn = sqlite3.connect(db_file)
    c = conn.cursor()

    for row in c.execute("""
        SELECT url, language 
        from media_streams, media_parts 
        where media_parts.file =? 
        and media_parts.id = media_streams.media_part_id 
        and media_streams.codec in ('srt', 'sub')""", [part.file]):
            subtitle_file = os.path.join(media_dir, row[0].replace('media://', ''))
            subtitle_lang = row[1]  # values are country codes 'eng', 'cze' ...
            Log.Debug(subtitle_file)
            Log.Debug(subtitle_lang)

    c.close()

from srt2utf-8.bundle.

ukdtom avatar ukdtom commented on May 31, 2024

Sadly....Your code is perfect, but direct access to the SQL database is not avail on all platforms, since most NAS devices can't do an include of sqlite, sue to a missing file.

And I have to provide this to all platforms ;-)

But when said....code is all most there, since I made it for another project
https://github.com/dagalufh/WebTools.bundle
already, so now "only" need to hook it in.

from srt2utf-8.bundle.

pristas-peter avatar pristas-peter commented on May 31, 2024

Oh yeah, you are right about sqlite, well the other solution to it is to dig that info through WEB API:
I guess this should work:

  • create Timer through Thread.CreateTimer()

inside that timer function:

  • localhost:32400/library/sections -> find out which section contains part's filename
  • localhost:32400/library/sections/[:id]/all -> find media which has file same as part.file and use 'key' attribute which has metadata id
  • localhost:32400/library/metadata/[:id]/tree -> and you have list of subtitles inside streams sections

from srt2utf-8.bundle.

ukdtom avatar ukdtom commented on May 31, 2024

Not possible either ;-)

This is an agent, running when a media is added, and due to that, it's not yet possible to access the web api for it ;-)

from srt2utf-8.bundle.

pristas-peter avatar pristas-peter commented on May 31, 2024

That's why i have mentioned Thread.CreateTimer(), the code would be executed in a seperate thread later, so it would work

from srt2utf-8.bundle.

ukdtom avatar ukdtom commented on May 31, 2024

Not needed...I get it handed down to me by the primary agent ;-)

You can follow my progress in the tommy-work branch, and are more than welcome to fork and add a pull request

from srt2utf-8.bundle.

ukdtom avatar ukdtom commented on May 31, 2024

And please take a peak here:

https://forums.plex.tv/index.php/topic/94864-rel-str2utf-8/?p=766258

from srt2utf-8.bundle.

pristas-peter avatar pristas-peter commented on May 31, 2024

Hi, I have done it, it works for Movies/Tv Shows and every subtitles agent, this agent should be the last in chain, but it is not mandatory:

https://github.com/pristas-peter/SRT2UTF-8.bundle/blob/master/Contents/Code/__init__.py

from srt2utf-8.bundle.

ukdtom avatar ukdtom commented on May 31, 2024

But....Did you see my req. for beta testers?

I also did it, but without spawning a thread, which IMHO would be better.

from srt2utf-8.bundle.

pristas-peter avatar pristas-peter commented on May 31, 2024

Yes, but it is only compatible with movies and opensubtitles, this is universal solution

from srt2utf-8.bundle.

ukdtom avatar ukdtom commented on May 31, 2024

True, but to be frank, I don't wanna use the http api due to speed, nor the threading metode, and I also want to be able to enable/disable the look for individual agents, as I've done so far in the beta.
If people test this, then it's easy to add support for others as well, like Podnapsi.
And regarding TV-Shows, then the code is already there, just remarked, since I wanted beta testers to test slowly.

from srt2utf-8.bundle.

pristas-peter avatar pristas-peter commented on May 31, 2024

Ok bro, whatever you want, it's your project... For me it works and I just wanted to share with the community...

from srt2utf-8.bundle.

ukdtom avatar ukdtom commented on May 31, 2024

Fixed in V0.0.2.0

from srt2utf-8.bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.