GithubHelp home page GithubHelp logo

Renaming of symlinks about cinesync HOT 13 CLOSED

eoghan2t9 avatar eoghan2t9 commented on August 18, 2024
Renaming of symlinks

from cinesync.

Comments (13)

sureshfizzy avatar sureshfizzy commented on August 18, 2024

Renaming is always been quite Challenging since it cannot be done without implementing API's. Even with them, it will be difficult to handle few names which cannot be completely automated. I need to check upon how to handle these.

from cinesync.

eoghan2t9 avatar eoghan2t9 commented on August 18, 2024

Happy days mate cheers I did do a quick search online apparently the mv command works to rename the symlink. Would it be possible to run filebot on the folder to see if that works lol

from cinesync.

sureshfizzy avatar sureshfizzy commented on August 18, 2024

you can manually rename the files using mv, but that method will be hard for all files since you have to do it one by one :). Also can you explain the second method,? Never came across with such thing

from cinesync.

eoghan2t9 avatar eoghan2t9 commented on August 18, 2024

Yeah to hell one by one renaming lol and filebot it's a tool used for renaming if files to make it easier for media parsers to get the correct metadata. It's a paid for product but could be easily added to your script if a user already has it installed.

https://www.filebot.net/

from cinesync.

sureshfizzy avatar sureshfizzy commented on August 18, 2024

I hope there is a demo version of it, I'll check the working on ubuntu and add it accordingly.

from cinesync.

eoghan2t9 avatar eoghan2t9 commented on August 18, 2024

I'll happy get you a years license if you want lol

from cinesync.

sureshfizzy avatar sureshfizzy commented on August 18, 2024

I'm learning on how it is implemented on sonarr :). It just picks the right name all time.

from cinesync.

eoghan2t9 avatar eoghan2t9 commented on August 18, 2024

Haha that it does but if needed I'll send you my filebot licence via email ;)

from cinesync.

sureshfizzy avatar sureshfizzy commented on August 18, 2024

I'm just worried about the users who doesn't have it

from cinesync.

eoghan2t9 avatar eoghan2t9 commented on August 18, 2024

You could possibly do something like this in python got help from chatgpt lol

import os
import re
import requests

# Function to query TMDb API for TV series
def query_tmdb_tv(api_key, query):
    url = "https://api.themoviedb.org/3/search/tv"
    params = {
        'api_key': api_key,
        'query': query
    }
    response = requests.get(url, params=params)
    if response.status_code == 200:
        return response.json()
    else:
        return None

# Function to query TMDb API for specific episode details
def query_tmdb_episode(api_key, tv_id, season_number, episode_number):
    url = f"https://api.themoviedb.org/3/tv/{tv_id}/season/{season_number}/episode/{episode_number}"
    params = {
        'api_key': api_key
    }
    response = requests.get(url, params=params)
    if response.status_code == 200:
        return response.json()
    else:
        return None

# Function to extract series name, season number, and episode number from file name
def extract_info(file_name):
    pattern = re.compile(r"(.+?)[. _-]+[sS](\d+)[eE](\d+)")
    match = pattern.match(file_name)
    if match:
        series_name = match.group(1).replace('.', ' ').replace('_', ' ').replace('-', ' ').strip()
        season_number = int(match.group(2))
        episode_number = int(match.group(3))
        return series_name, season_number, episode_number
    return None, None, None

# Main function
def main():
    api_key = 'YOUR_TMDB_API_KEY'
    media_folder = 'path/to/your/media/files'

    for file_name in os.listdir(media_folder):
        if os.path.isfile(os.path.join(media_folder, file_name)):
            series_name, season_number, episode_number = extract_info(file_name)
            if series_name and season_number and episode_number:
                print(f"Querying TMDb for TV series: {series_name}, Season: {season_number}, Episode: {episode_number}")
                result = query_tmdb_tv(api_key, series_name)
                if result and result['results']:
                    # Get the first result from the list
                    series_info = result['results'][0]
                    tv_id = series_info['id']
                    episode_info = query_tmdb_episode(api_key, tv_id, season_number, episode_number)
                    if episode_info:
                        print(f"Series: {series_info['name']}")
                        print(f"Season: {season_number}, Episode: {episode_number}")
                        # Print the episode title
                        print(f"Episode Title: {episode_info['name']}")
                        print(f"Air Date: {episode_info['air_date']}")
                        print(f"Overview: {episode_info['overview']}")
                    else:
                        print(f"No episode information found for: {series_name}, Season: {season_number}, Episode: {episode_number}")
                else:
                    print(f"No results found for: {series_name}")
            else:
                print(f"File name does not match expected pattern: {file_name}")

if __name__ == "__main__":
    main()

from cinesync.

sureshfizzy avatar sureshfizzy commented on August 18, 2024

You could possibly do something like this in python got help from chatgpt lol

import os
import re
import requests

# Function to query TMDb API for TV series
def query_tmdb_tv(api_key, query):
    url = "https://api.themoviedb.org/3/search/tv"
    params = {
        'api_key': api_key,
        'query': query
    }
    response = requests.get(url, params=params)
    if response.status_code == 200:
        return response.json()
    else:
        return None

# Function to query TMDb API for specific episode details
def query_tmdb_episode(api_key, tv_id, season_number, episode_number):
    url = f"https://api.themoviedb.org/3/tv/{tv_id}/season/{season_number}/episode/{episode_number}"
    params = {
        'api_key': api_key
    }
    response = requests.get(url, params=params)
    if response.status_code == 200:
        return response.json()
    else:
        return None

# Function to extract series name, season number, and episode number from file name
def extract_info(file_name):
    pattern = re.compile(r"(.+?)[. _-]+[sS](\d+)[eE](\d+)")
    match = pattern.match(file_name)
    if match:
        series_name = match.group(1).replace('.', ' ').replace('_', ' ').replace('-', ' ').strip()
        season_number = int(match.group(2))
        episode_number = int(match.group(3))
        return series_name, season_number, episode_number
    return None, None, None

# Main function
def main():
    api_key = 'YOUR_TMDB_API_KEY'
    media_folder = 'path/to/your/media/files'

    for file_name in os.listdir(media_folder):
        if os.path.isfile(os.path.join(media_folder, file_name)):
            series_name, season_number, episode_number = extract_info(file_name)
            if series_name and season_number and episode_number:
                print(f"Querying TMDb for TV series: {series_name}, Season: {season_number}, Episode: {episode_number}")
                result = query_tmdb_tv(api_key, series_name)
                if result and result['results']:
                    # Get the first result from the list
                    series_info = result['results'][0]
                    tv_id = series_info['id']
                    episode_info = query_tmdb_episode(api_key, tv_id, season_number, episode_number)
                    if episode_info:
                        print(f"Series: {series_info['name']}")
                        print(f"Season: {season_number}, Episode: {episode_number}")
                        # Print the episode title
                        print(f"Episode Title: {episode_info['name']}")
                        print(f"Air Date: {episode_info['air_date']}")
                        print(f"Overview: {episode_info['overview']}")
                    else:
                        print(f"No episode information found for: {series_name}, Season: {season_number}, Episode: {episode_number}")
                else:
                    print(f"No results found for: {series_name}")
            else:
                print(f"File name does not match expected pattern: {file_name}")

if __name__ == "__main__":
    main()

need to check this, can you try it locally ?

from cinesync.

eoghan2t9 avatar eoghan2t9 commented on August 18, 2024

Not at the moment as I'm not at home but I will later when I'm home again

from cinesync.

sureshfizzy avatar sureshfizzy commented on August 18, 2024

I'll check on this tomorrow.

from cinesync.

Related Issues (9)

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.